Created
February 14, 2012 17:28
-
-
Save Bronsa/1828382 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn fnil [f & vals] | |
(fn [& args] | |
(apply f (loop [acc [] maybe-nils args vals vals] | |
(if maybe-nils | |
(if (nil? (first maybe-nils)) | |
(recur (conj acc (first vals)) (next maybe-nils) (rest vals)) | |
(recur (conj acc (first maybe-nils)) (next maybe-nils) vals)) | |
acc))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment