Skip to content

Instantly share code, notes, and snippets.

@jasonjohnson
Created November 1, 2012 01:14
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 jasonjohnson/3990998 to your computer and use it in GitHub Desktop.
Save jasonjohnson/3990998 to your computer and use it in GitHub Desktop.
; I have a bunch of these "example"-type functions:
(defn example [a b c] (str a b c))
; Imagine incoming calls which look like this:
(def testing '(example 2 3))
; My naive first attempt. Prints the string "123"
(println (apply (partial (resolve (first testing)) 1) (rest testing)))
; So, I've pre-applied the first argument to the function!
; What I'm looking for would look like this:
(with-account account
(do-first-thing arg2 arg3)
(do-second-thing arg2 arg3)
(do-third-thing arg2 arg3))
; Which would expand to:
(do-first-thing account arg2 arg3)
(do-second-thing account arg2 arg3)
(do-third-thing account arg2 arg3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment