Skip to content

Instantly share code, notes, and snippets.

@yuanmai
Created April 27, 2013 10:56
Show Gist options
  • Select an option

  • Save yuanmai/5472682 to your computer and use it in GitHub Desktop.

Select an option

Save yuanmai/5472682 to your computer and use it in GitHub Desktop.
binding dynamic var
user> (def ^:dynamic *foo* nil)
#'user/*foo*
user> *foo*
nil
user> (defn f [] *foo*)
#'user/f
user> (f)
nil
user> (binding [*foo* 1] (f))
1
user> (binding [*foo* 1] (lazy-seq [(f)]))
(nil)
user> (binding [*foo* 1] (doall (lazy-seq [(f)])))
(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment