Skip to content

Instantly share code, notes, and snippets.

@noidi
Created March 25, 2010 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noidi/343741 to your computer and use it in GitHub Desktop.
Save noidi/343741 to your computer and use it in GitHub Desktop.
(defn maybe-reduce [f a l]
"Short-circuits if f returns nil."
(if (seq l)
(let [[b & cs] l
fab (f a b)]
(if cs
(if (nil? fab)
nil
(recur f fab cs))
fab))
a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment