aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2025-02-10 07:13:16 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2025-02-11 00:40:19 +0000
commitc5d98886410d46838e5863066edf37e544a72456 (patch)
tree9f61f6c49c85fa8269dfe82db8278af928b48f52
parentef572b992b57011efd6dbfe649b0ba68f5f5f320 (diff)
downloadcantedraw-c5d98886410d46838e5863066edf37e544a72456.tar.gz
cantedraw-c5d98886410d46838e5863066edf37e544a72456.tar.bz2
cantedraw-c5d98886410d46838e5863066edf37e544a72456.zip
functions -> forms in lib.macros
-rw-r--r--lib.macros.lisp17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib.macros.lisp b/lib.macros.lisp
index 057a89f..5489564 100644
--- a/lib.macros.lisp
+++ b/lib.macros.lisp
@@ -19,7 +19,7 @@
(in-package :lib.macros)
-(defmacro --> (&rest functions)
+(defmacro --> (&rest forms)
"Lexically bind current form as `_' for use in the next form, returning the
result of the last form.
@@ -34,30 +34,29 @@ i.e.
Also includes transformer where symbols are considered unary functions i.e.
(--> x y) <-> (--> x (y _)).
"
- (if (null functions)
+ (if (null forms)
nil
(let ((assignment-forms
- (loop :for f :in functions
+ (loop :for f :in forms
:for canon-f = (if (symbolp f) (list f 'lib.macros:_) f)
:collect `(lib.macros:_ ,canon-f))))
`(let* ,assignment-forms
lib.macros:_))))
-(defmacro ->> (&rest functions)
+(defmacro ->> (&rest forms)
"Make current form the last argument of the next form, returning the last
form.
i.e.
(->> (a1 a2...) (b1 b2...) (c1 c2...)) == (c1 c2 ... (b1 b2 ... (a1 a2 ...)))
-Also includes transformer where fun in functions that are symbols are considered
-unary functions.
+Also includes transformer where symbols are considered unary functions.
Like the `|>' operator in Ocaml."
- (if (null functions)
+ (if (null forms)
nil
- (loop :with acc = (car functions)
- :for func :in (cdr functions)
+ (loop :with acc = (car forms)
+ :for func :in (cdr forms)
:for canon-func = (if (symbolp func) (list func) func)
:do (setq acc (append canon-func (list acc)))
:finally (return acc))))