Created
August 30, 2010 20:35
-
-
Save tcrayford/558007 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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)))))) |
This file contains hidden or 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
(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