2 ms·
Composable, lazily evaluated map, filter and fold in C90: This is the TXR Lisp interactive listener of TXR 204. Quit with :quit or Ctrl-D on empty line. Ct
by kazinator 8y ago
Composable, lazily evaluated map, filter and fold in C90:
This is the TXR Lisp interactive listener of TXR 204.
Quit with :quit or Ctrl-D on empty line. Ctrl-X ? for cheatsheet.
1> (take 15 [keep-if* oddp (mapcar* [dup *] (range 0))])
(1 9 25 49 81 121 169 225 289 361 441 529 625 729 841)
Lazy keep-if: http://www.kylheku.com/cgit/txr/tree/lib.c?id=c310771b221125d3ff419662ce74f6b505fe638f#n1874 http://www.kylheku.com/cgit/txr/tree/lib.c?id=c310771b221125...
Lazy mapcar: http://www.kylheku.com/cgit/txr/tree/eval.c?id=c310771b221125d3ff419662ce74f6b505fe638f#n5170 http://www.kylheku.com/cgit/txr/tree/eval.c?id=c310771b22112...
Lazy range: http://www.kylheku.com/cgit/txr/tree/eval.c?id=c310771b221125d3ff419662ce74f6b505fe638f#n5397 http://www.kylheku.com/cgit/txr/tree/eval.c?id=c310771b22112...
P.S. dup generates a one-argument function which duplicates its argument into two places and calls another function. [dup *] gives us a squaring function, thus.