Seems like a good use of “delay”, yeah? Slightly different calling semantics, of course, but still:
user> (def f (delay (gensym "node"))) #'user/f user> @f node3330 user> @f node3330 Sam Ritchie (@sritchie) RaceHub Co-Founder 703.863.8561 www.racehubhq.com <http://www.racehubhq.com/> Twitter <http://twitter.com/racehubhq> // Facebook <http://facebook.com/racehubhq> > On Sep 11, 2015, at 6:12 PM, Sean Corfield <[email protected]> wrote: > >> (memoize (fn [_#] (gensym "node")) >> >> How is that different than >> >> (gensym "node") > > > The latter returns a string, e.g., "node18051", the former returns a function > that, when called, returns a string. Wrapping it in memoize just ensures that > if you call it multiple times with the same argument, you get back the same > string each time: > > (def f (memoize (fn [_#] (gensym "node")))) > #'user/f > user> (f 1) > node18056 > user> (f 1) > node18056 > user> (f 2) > node18061 > user> (f 2) > node18061 > user> (f 3) > node18066 > > Sean > > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to [email protected] > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > <http://groups.google.com/group/clojure?hl=en> > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
