Skip to content

Instantly share code, notes, and snippets.

@sritchie
Created March 31, 2011 05:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sritchie/895876 to your computer and use it in GitHub Desktop.
Save sritchie/895876 to your computer and use it in GitHub Desktop.
(defmacro phase-fn
([argvec] identity)
([argvec & forms]
`(fn [session# ~@argvec]
(--> session#
~(first forms)
~(fn [x#] (do (println x#) x#))
~(if (seq (rest forms))
`((phase-fn ~argvec ~@(rest forms)))
`((phase-fn ~argvec)))))))
(defmacro phase-fn
([argvec] identity)
([argvec & forms]
(let [subphase# (first forms)
left# (rest forms)]
`(fn [session# ~@argvec]
(--> session#
~subphase#
~@(when (seq left#)
[`((phase-fn ~argvec ~@left#))])))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment