Skip to content

Instantly share code, notes, and snippets.

@raek
Created October 21, 2010 19:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raek/639185 to your computer and use it in GitHub Desktop.
Save raek/639185 to your computer and use it in GitHub Desktop.
(defn with-default-args [f & default-args]
(fn [& args]
(apply f (->> default-args
(drop (count args))
(concat args)))))
(comment ; usage
(def f (with-default-args + 1 2))
(f)
=> 3
(f 0)
=> 2
(f 0 0)
=> 0
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment