; Move -doto/--doto next to other threading macros

master
Basil L. Contovounesios 5 years ago
parent d983d4fea0
commit 5a64259a35
No known key found for this signature in database
GPG Key ID: 205AB54A5D5D8CFF
  1. 42
      dash.el

@ -62,27 +62,6 @@
(setq it-index (1+ it-index))
(!cdr ,l)))))
(defmacro -doto (init &rest forms)
"Evaluate INIT and pass it as argument to FORMS with `->'.
The RESULT of evaluating INIT is threaded through each of FORMS
individually using `->', which see. The return value is RESULT,
which FORMS may have modified by side effect."
(declare (debug (form body)) (indent 1))
(let ((retval (make-symbol "result")))
`(let ((,retval ,init))
,@(mapcar (lambda (form) `(-> ,retval ,form)) forms)
,retval)))
(defmacro --doto (init &rest forms)
"Anaphoric form of `-doto'.
This just evaluates INIT, binds the result to `it', evaluates
FORMS, and returns the final value of `it'.
Note: `it' need not be used in each form."
(declare (debug (form body)) (indent 1))
`(let ((it ,init))
,@forms
it))
(defun -each (list fn)
"Call FN with every item in LIST. Return nil, used for side-effects only."
(declare (indent 1))
@ -1607,6 +1586,27 @@ and when that result is non-nil, through the next form, etc."
(--> ,result ,form))
,@more))))
(defmacro -doto (init &rest forms)
"Evaluate INIT and pass it as argument to FORMS with `->'.
The RESULT of evaluating INIT is threaded through each of FORMS
individually using `->', which see. The return value is RESULT,
which FORMS may have modified by side effect."
(declare (debug (form body)) (indent 1))
(let ((retval (make-symbol "result")))
`(let ((,retval ,init))
,@(mapcar (lambda (form) `(-> ,retval ,form)) forms)
,retval)))
(defmacro --doto (init &rest forms)
"Anaphoric form of `-doto'.
This just evaluates INIT, binds the result to `it', evaluates
FORMS, and returns the final value of `it'.
Note: `it' need not be used in each form."
(declare (debug (form body)) (indent 1))
`(let ((it ,init))
,@forms
it))
(defun -grade-up (comparator list)
"Grade elements of LIST using COMPARATOR relation, yielding a
permutation vector such that applying this permutation to LIST

Loading…
Cancel
Save