diff options
author | Colin Okay <cbeok@protonmail.com> | 2020-07-30 08:48:13 -0500 |
---|---|---|
committer | Colin Okay <cbeok@protonmail.com> | 2020-07-30 08:48:13 -0500 |
commit | 057af65f5e6d6bf6a31ec5484ac23a7ce845157d (patch) | |
tree | 72389b52fd0d0f9d1151620d955f96f2648b1e55 /anaphora.lisp | |
parent | 571ae6bfdb3191dda97892bc8b3112958c83a84a (diff) |
added anaphoric FOLD and FOR
Diffstat (limited to 'anaphora.lisp')
-rw-r--r-- | anaphora.lisp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/anaphora.lisp b/anaphora.lisp new file mode 100644 index 0000000..13bb980 --- /dev/null +++ b/anaphora.lisp @@ -0,0 +1,26 @@ +(in-package #:gtwiwtg.anaphora) + +(defmacro afor (generator &body body) + "Anaphoric FOR. Binds the values produced by GENERATOR to the variable IT. + +Example: + +> (afor (times 3) (print it)) +0 +1 +2 + +" + `(for it ,expr ,@body)) + +(defmacro afold (init generator update) + "Anaphoric FOLD. Binds the values produced by GENERATOR to IT, and +binds the accumulating variable to ACC. + +Example: + +> (afold 0 (times 10) (+ acc it)) +45 + +" + `(fold (acc ,init) (it ,expr) ,update)) |