Meta operators (III)
- Another meta operator which works on arrays/lists is reduce:
-
[+] @a
sums all of the elements of @a
and returns the sum
- It's functionally equivalent to
@a[0] + @a[1] + ... + @a[*-1]
- Any infix operator can be used in place of
+
there
- Obviously this will not work for infinite lazy lists
- But there is another form of the reduce meta operator which returns a lazy list
-
[\*] 1...*
returns the lazy list 1, 1*2, 1*2*3, 1*2*3*4 ...
- That is to say, it returns each internal step of the evaluation of
[*]
« first
< prev
(36 / 41)
next >
last »