|
|
|
|
@ -1354,17 +1354,29 @@ last item in second form, etc." |
|
|
|
|
(list form x))) |
|
|
|
|
(:else `(->> (->> ,x ,form) ,@more)))) |
|
|
|
|
|
|
|
|
|
(defmacro --> (x form &rest more) |
|
|
|
|
"Thread the expr through the forms. Insert X at the position |
|
|
|
|
signified by the token `it' in the first form. If there are more |
|
|
|
|
forms, insert the first form at the position signified by `it' in |
|
|
|
|
in second form, etc." |
|
|
|
|
(declare (debug (form &rest [&or symbolp (sexp &rest [&or "it" form])]))) |
|
|
|
|
(if (null more) |
|
|
|
|
(if (listp form) |
|
|
|
|
(--map-when (eq it 'it) x form) |
|
|
|
|
(list form x)) |
|
|
|
|
`(--> (--> ,x ,form) ,@more))) |
|
|
|
|
(defmacro --> (x &rest forms) |
|
|
|
|
"Starting with the value of X, thread each expression through FORMS. |
|
|
|
|
|
|
|
|
|
Insert X at the position signified by the token `it' in the first |
|
|
|
|
form. If there are more forms, insert the first form at the position |
|
|
|
|
signified by `it' in in second form, etc." |
|
|
|
|
(declare (debug (form body))) |
|
|
|
|
`(-as-> ,x it ,@forms)) |
|
|
|
|
|
|
|
|
|
(defmacro -as-> (value variable &rest forms) |
|
|
|
|
"Starting with VALUE, thread VARIABLE through FORMS. |
|
|
|
|
|
|
|
|
|
In the first form, bind VARIABLE to VALUE. In the second form, bind |
|
|
|
|
VARIABLE to the result of the first form, and so forth." |
|
|
|
|
(declare (debug (form symbolp body))) |
|
|
|
|
(if (null forms) |
|
|
|
|
`,value |
|
|
|
|
`(let ((,variable ,value)) |
|
|
|
|
(-as-> ,(if (symbolp (car forms)) |
|
|
|
|
(list (car forms) variable) |
|
|
|
|
(car forms)) |
|
|
|
|
,variable |
|
|
|
|
,@(cdr forms))))) |
|
|
|
|
|
|
|
|
|
(defmacro -some-> (x &optional form &rest more) |
|
|
|
|
"When expr is non-nil, thread it through the first form (via `->'), |
|
|
|
|
|