git @ Cat's Eye Technologies Quylthulg / 2e79f56
Add another example program. Reformat the boolean demo in tests. Chris Pressey 4 years ago
2 changed file(s) with 19 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
0 foreach $x$ = [10, 20, 40, 80, 60, 10, 30]
1 with $a$ = null be
2 ,$x$,$a$,
3 else be
4 null
9494 | foreach $n$=[1,2,3] with $a$=null be ,$n$,$a$, else be null
9595 = Cons (Int 3) (Cons (Int 2) (Cons (Int 1) Null))
9696
97 This is how boolean expressions can be built with `foreach`es.
98 We take `null` to mean **false** and `[1]` to mean **true**.
99
100 Boolean NOT.
101
102 | foreach $n$=null with $a$=null be null else be [1]
103 = Cons (Int 1) Null
104
105 | foreach $n$=[1] with $a$=null be null else be [1]
106 = Null
107
108 Boolean OR.
109
97110 | foreach $n$=;[1];[1]; with $a$=[1] be $a$ else be null
98111 = Cons (Int 1) Null
99112
106119 | foreach $n$=;null;null; with $a$=[1] be $a$ else be null
107120 = Null
108121
109 This is how boolean expressions can be built with foreaches.
122 Boolean AND.
110123
111124 | foreach $n$=[1] with $a$=[1] be
112125 | foreach $m$=$a$ with $b$=null be [1]