-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfor-comprehensions-comprehensive.cal
28 lines (25 loc) · 1.18 KB
/
for-comprehensions-comprehensive.cal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
namespace test:
actor test() ==> :
List(type: int, size=2) a := [1,2];
action ==>
var
List l1 := [a[i] * a[i]: for int i in [0,1]],
List l2 := [x, x+y, x+y+z : for x in [1,2,3], x > 1, x < 20, for y in 0..x, y > 1, for z in [5,6,7], y + z > x],
List l3 := [x : for x in [1,2,3,4]],
List l4 := [x+y : for x in [1,2,3], for y in [5,6,7]],
List l5 := let b = 5 : [a*b : for a in [1,2,3], b > 2*a, for b in [4,5,6]] end,
List l6 := let b = 5, c = 6 : [a*b, c : for a in (b-4)..(c-3), b > 2*a, for b in (b-1)..(c), b < c, for c in (c+1)..(c+3)] end
//int tempVar := 10
// List l6 := let b = 5, c = 6 : [a*b, c : for a in [1,2,3], b > 2*a, for b in [4,5,6], b < c, for c in [7,8,9]] end
// List l7 := [x+y : for x, y, z in [1,2,3], [4,5,6,7], [8,9,10,11,12]]
do
foreach List l in [l1, l2, l3, l4, l5, l6] do
foreach int c in l do
println(c);
end
end
// tempList := let c = 6 : [a*tempVar, c : for a in (tempVar-4)..(c-3), tempVar > 2*a, for tempVar in (tempVar-1)..(c), tempVar < c, for c in (c+1)..(c+3)] end;
// println(tempVar);
end
end
end