Skip to content

Instantly share code, notes, and snippets.

@Gonzih
Forked from anonymous/flip.clj
Last active December 10, 2015 12:48
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 Gonzih/4436070 to your computer and use it in GitHub Desktop.
Save Gonzih/4436070 to your computer and use it in GitHub Desktop.
(defn flip
"Flips a functions argument list."
[f] (fn [& args] (apply f (reverse args))))
;Slightly shorter implementation by Anthony Grimes @IORayne
(defn flip [f] #(apply f (reverse %&)))
(def my-gt (flip >))
(> 10 9); => true
(my-gt 10 9); => false
(def my-after? (flip after?))
(after? (date-time 1986 10) (date-time 1986 9)); => true
(my-after? (date-time 1986 10) (date-time 1986 9)); => false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment