bindings => x xs
Same as (when (seq xs) (let [x (first xs)] body))
(defmacro when-first
"bindings => x xs
Same as (when (seq xs) (let [x (first xs)] body))"
{:added "1.0"}
[bindings & body]
(assert-args when-first
(vector? bindings) "a vector for its binding"
(= 2 (count bindings)) "exactly 2 forms in binding vector")
(let [[x xs] bindings]
`(when (seq ~xs)
(let [~x (first ~xs)]
~@body))))
Comments top
No comments for when-first. Log in to add a comment.