Code: Select all
foreach and [ || ]
The
Code: Select all
findall, list::map and list:forall
Shall I forget them and use
Code: Select all
foreach and [ || ]
Code: Select all
foreach and [ || ]
Code: Select all
findall, list::map and list:forall
Code: Select all
foreach and [ || ]
Code: Select all
....
Z=list::map(Xs, Y),
...
Code: Select all
...
C=varM:new(),
foreach X in Xs do
C:value:=list::append(C:value, Y(X))
end foreach,
Z=C:value,
...
Code: Select all
% map
Ma = map(L, f),
Mb = [ f(X) || X in L],
% forall
forall(L, p),
foreach Y in L do
p(Y)
end foreach
Code: Select all
Z = q(...),
% map
Ma =
map(L,
{ (X) = f(V, Z) :-
V1 = g(Z, 12),
V2 = h(V1)
}),
Mb =
[ f(V, Z) ||
X in L,
V1 = g(Z, 12),
V2 = h(V1)
],
% forall
forall(L,
{ (Y) :-
V1 = a(Y, Z),
V2 = b(Y, V1),
p(V2)
}),
foreach Y in L do
V1 = a(Y, Z),
V2 = b(Y, V1),
p(V2)
end foreach.