Skip to content

Instantly share code, notes, and snippets.

@Bronsa Bronsa/fnil.clj
Created Feb 14, 2012

What would you like to do?
(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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.