git @ Cat's Eye Technologies
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).
 0 foreach \$x\$ = [10, 20, 40, 80, 60, 10, 30] 1 with \$a\$ = null be 2 ,\$x\$,\$a\$, 3 else be 4 null
 94 94 | foreach \$n\$=[1,2,3] with \$a\$=null be ,\$n\$,\$a\$, else be null 95 95 = Cons (Int 3) (Cons (Int 2) (Cons (Int 1) Null)) 96 96 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 97 110 | foreach \$n\$=;[1];[1]; with \$a\$=[1] be \$a\$ else be null 98 111 = Cons (Int 1) Null 99 112 106 119 | foreach \$n\$=;null;null; with \$a\$=[1] be \$a\$ else be null 107 120 = Null 108 121 109 This is how boolean expressions can be built with foreaches. 122 Boolean AND. 110 123 111 124 | foreach \$n\$=[1] with \$a\$=[1] be 112 125 | foreach \$m\$=\$a\$ with \$b\$=null be [1]