git @ Cat's Eye Technologies Quylthulg / 344d2dd
Add another example source, 2 test cases, minor edits to README. Chris Pressey 4 years ago
3 changed file(s) with 14 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
146146
147147 There is also an operator `;` which appends one list (the right-hand
148148 side) onto the end of another list (the left-hand side.) This is
149 probably not strictly necessary, since as we'll see later can probably
149 probably not strictly necessary, since as we'll see later we can probably
150150 build something equivalent using `foreach`es and macros, but what the
151151 hell, we can afford it. Party down.
152152
167167 operator. The value that the body evaluates to is used as the
168168 accumulator for the next time the body is evaluated, on the next value
169169 in the data structure. The value that `foreach` evaluates to is the
170 value of the FINAL accumulator (emphasis mine.) The full form of this
170 value of the **final** accumulator (emphasis mine.) The full form of this
171171 operator is as follows:
172172
173173 foreach $var$ = data-expr with $acc$ = initial-expr be loop-expr else be otherwise-expr
179179 (sub)list, `foreach` will begin traversing that (sub)list (with the
180180 same body and current accumulator, natch) instead of passing the
181181 (sub)list to the body; and
182 - *abortable*, meaning that the loop-expr may evaluate to a special
182 - *abortable*, meaning that the *loop-expr* may evaluate to a special
183183 value `abort`, which causes traversal of the current (sub)list to
184184 cease immediately, returning to the traversal of the containing
185185 list, if any.
0 foreach $x$ = [10, 20, 40]
1 with $a$ = ,0,0, be
2 ,+<$a$<0<+1+,+>$a$>0>+$x$+,
3 else be
4 null
5151
5252 | >1>null>
5353 = Null
54
55 | <,1,2,<null<
56 = Int 1
57
58 | >,1,2,>null>
59 = Int 2
5460
5561 | ,1,,2,3,,
5662 = Cons (Int 1) (Cons (Int 2) (Int 3))