Merge pull request #144 from cammsaul/thread_last_make_second_arg_optional

Make ->>'s second arg optional
master
Matus Goljer 11 years ago
commit 70caa37eed
  1. 13
      dash.el

@ -1168,16 +1168,17 @@ second item in second form, etc."
(list form x))) (list form x)))
(:else `(-> (-> ,x ,form) ,@more)))) (:else `(-> (-> ,x ,form) ,@more))))
(defmacro ->> (x form &rest more) (defmacro ->> (x &optional form &rest more)
"Thread the expr through the forms. Insert X as the last item "Thread the expr through the forms. Insert X as the last item
in the first form, making a list of it if it is not a list in the first form, making a list of it if it is not a list
already. If there are more forms, insert the first form as the already. If there are more forms, insert the first form as the
last item in second form, etc." last item in second form, etc."
(if (null more) (cond
(if (listp form) ((null form) x)
`(,(car form) ,@(cdr form) ,x) ((null more) (if (listp form)
(list form x)) `(,@form ,x)
`(->> (->> ,x ,form) ,@more))) (list form x)))
(:else `(->> (->> ,x ,form) ,@more))))
(defmacro --> (x form &rest more) (defmacro --> (x form &rest more)
"Thread the expr through the forms. Insert X at the position "Thread the expr through the forms. Insert X at the position

Loading…
Cancel
Save