Re: Why (memoize (fn [_#] (gensym "node")) in rhizome?

2015-09-13 Thread Lawrence Krubner
> Memoize takes the ignored argument into account 
> when associating the inputs with outputs.

This is the answer I was looking for. I feel like this is the subtlety that 
I had missed. 




On Saturday, September 12, 2015 at 5:24:55 AM UTC-4, Moe Aboulkheir wrote:
>
>
>
> On Sat, Sep 12, 2015 at 1:58 AM, Sam Ritchie  > 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.


Re: Why (memoize (fn [_#] (gensym "node")) in rhizome?

2015-09-13 Thread Gary Verhaegen
Because the form appears in a syntax-quote, the # is required to,ask
syntax-quote to create an identifier rather than resolve it to the current
namespace.

On Sunday, 13 September 2015, Akhil Wali  wrote:

> What does _# mean opposed to simply _? With respect to memoization of
> genus it's the same thing IMHO.
>
> --
> 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.
>

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


Re: Why (memoize (fn [_#] (gensym "node")) in rhizome?

2015-09-12 Thread Akhil Wali
What does _# mean opposed to simply _? With respect to memoization of genus 
it's the same thing IMHO.

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


Re: Why (memoize (fn [_#] (gensym "node")) in rhizome?

2015-09-12 Thread Sam Ritchie
Ah, of course. Even though the guts of the function are ignoring the argument, 
`memoize` is using it. Cool!

Sam Ritchie (@sritchie)
RaceHub Co-Founder
703.863.8561
www.racehubhq.com 
Twitter  // Facebook 



> On Sep 12, 2015, at 3:24 AM, Moe Aboulkheir  wrote:
> 
> 
> 
> On Sat, Sep 12, 2015 at 1:58 AM, Sam Ritchie  > 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 
> .

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


Re: Why (memoize (fn [_#] (gensym "node")) in rhizome?

2015-09-12 Thread Moe Aboulkheir
On Sat, Sep 12, 2015 at 1:58 AM, Sam Ritchie  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.


Re: Why (memoize (fn [_#] (gensym "node")) in rhizome?

2015-09-11 Thread Sam Ritchie
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 
Twitter  // Facebook 



> On Sep 11, 2015, at 6:12 PM, Sean Corfield  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 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 
> .

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


Re: Why (memoize (fn [_#] (gensym "node")) in rhizome?

2015-09-11 Thread Sean Corfield
(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 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.