Skip to content

Instantly share code, notes, and snippets.

@sherpc
Created April 20, 2013 21:16
Show Gist options
  • Save sherpc/5427466 to your computer and use it in GitHub Desktop.
Save sherpc/5427466 to your computer and use it in GitHub Desktop.
(defmacro defn-nil
[fname args body]
`(defn ~fname ~args (if (nil? ~(first args)) nil ~body)))
(defn-nil f
[x y]
(+ x y))
(f 1 2) ;; => 3
(f nil 2) ;; => nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment