Skip to content

Instantly share code, notes, and snippets.

@tcrayford
Created August 30, 2010 20:35
Show Gist options
  • Save tcrayford/558007 to your computer and use it in GitHub Desktop.
Save tcrayford/558007 to your computer and use it in GitHub Desktop.
(defn some-name [f] ;; Takes a function that
(fn [& fns] ;; Returns a function that takes a list of functions that returns
(fn [& args] ;; A function that calls the original function with identity over applying each function to the args of this anonymous function #ohgod
(f identity (map apply fns (repeat args))))))
(def orf (some-name some)) ;; Takes a list of functions and returns a function that "ors" over the results of applying each fn to its args.
(defn andf (some-name every?)) ;; Takes a list of functions and returns a function that "ands" over the results of applying each fn to its args.
Usage of these:
((orf map? :a) something)
is equivalent to
(or (map? something)
(:a something))
((andf map? :a) something)
is equivalent to
(and (map? something)
(:a something))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment