On Sat, Sep 12, 2015 at 1:58 AM, Sam Ritchie <sritchi...@gmail.com> wrote:

> 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
>

The original code wanted different behaviour - a distinct gensym for each
distinct input.  Memoize takes the ignored argument into account when
associating the inputs with outputs.

user> (def mapped-gensym (memoize (fn [_] (gensym "alias"))))

user> (mapped-gensym "HI")
alias29367
user> (mapped-gensym "HI")
alias29367
user> (mapped-gensym "NOT HI")
alias29372

Take care,
Moe

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to