Rework $ operator to take a capture variable

In case operators require use of a variable, we should let the caller
provide the symbol so we don't fall into weird package issues.
This commit is contained in:
2025-02-15 15:04:00 +00:00
parent be61832737
commit 395cd9357e
2 changed files with 4 additions and 4 deletions

View File

@@ -80,11 +80,11 @@ arguments `LAMBDA-LIST' with body `BODY'."
(defun ,name ,lambda-list (defun ,name ,lambda-list
,@body))) ,@body)))
(defmacro $ (&rest forms) (defmacro $ (capture &rest forms)
"Given a sequence of FORMS, return a unary function which applies each form "Given a sequence of FORMS, return a unary function which applies each form
sequentially" sequentially"
`(lambda (x) `(lambda (,capture)
(->> x ,@forms))) (->> ,capture ,@forms)))
(defmacro alist-val (key alist) (defmacro alist-val (key alist)
"Helper macro for getting the value of KEY in ALIST." "Helper macro for getting the value of KEY in ALIST."

View File

@@ -133,5 +133,5 @@
(loop :for _ :from 1 :to n (loop :for _ :from 1 :to n
:nconc (loop :for j :from 1 :to 52 :nconc (loop :for j :from 1 :to 52
collect (int->card (1- j)))) collect (int->card (1- j))))
(mapcar ($ int->rank make-joker) (mapcar ($ x int->rank make-joker)
(range 0 (* 2 n))))) (range 0 (* 2 n)))))