The base foreach

The base form of foreach has the following form:


aa aaa aaa aaa aaa aaa aaa 
		 		 foreach(E1 in D1, $\ldots$, En in Dn, LocalVars,Goal) 

Ei is a pattern that is normally a variable, but can also be any term. Di a collection. LocalVars, which is optional, is a list of variables in Goal that are local to each iteration. Goal is a callable term. All of the variables in the Ei's are local variables. The foreach call means that, for each combination of values $E_1 \in D_1$, $\ldots$, $E_n \in D_n$, the instance Goal is executed after the local variables are renamed. The call fails if any of the instances fails. Any variable, including the anonymous variable '_', that occurs in Goal, is shared by all iterations, unless the variable is contained within an Ei or LocalVars.

A collection takes one of the following forms:



Subsections
Neng-Fa Zhou 2013-01-25