Thanks.
That sound good.
I had played with eval, but wasn happy about this.



2013/7/31 Cedric Greevey <cgree...@gmail.com>

> If you saved the original function instance, you can use it to find the
> map. This should work:
>
> (let [f #(+ 1 1)
>       s #{{:a 3 :b 5 :c f}}]
>   (contains? s {:a 3 :b 5 :c f}))
>
> Note that the value for the :c key is now the same *instance* of that
> function.
>
> Storing the function source, with ', instead of the function itself works
> until you want to call the function. Then you need eval. You might want to
> avoid that, perhaps by using a map of quoted functions to compiled
> functions (you can also use something similar to avoid compiling each
> single one of these functions over and over again at runtime even if you do
> use eval -- or just (def meval (memoize eval)) and use meval, or something).
>
> If you don't use eval, you can use other keys instead of the function
> source; a suitable keyword name like :add-x might be good, so you'd end up
> with {:a 3 :b 5 :c :add-x} in your data structure and a {:add-x #(+ 1 1)}
> in a lookup table somewhere.
>
>
>
> On Wed, Jul 31, 2013 at 6:34 AM, Marcus Lindner <
> marcus.goldritter.lind...@gmail.com> wrote:
>
>> Ups. [?]
>> Sorry.
>> Have not seen this typo :(.
>>
>>
>> 2013/7/31 Jim <jimpil1...@gmail.com>
>>
>>> On 31/07/13 11:01, Goldritter wrote:
>>>
>>>> But when I tried to access the value I got an Exception
>>>> =>(c: {:a 3 :h 5 :c '#(+ 1 1)})
>>>> RuntimeException Invalid token: c: clojure.lang.Util.**runtimeException
>>>> (Util.java:219)
>>>> {:a 3, :c (fn* [] (+ 1 1)), :h 5}
>>>>
>>>> The same with get
>>>> => (get {:a 3 :h 5 :c '#(+ 1 1)} c:)
>>>> RuntimeException Invalid token: c: clojure.lang.Util.**runtimeException
>>>> (Util.java:219)
>>>> RuntimeException Unmatched delimiter: ) 
>>>> clojure.lang.Util.**runtimeException
>>>> (Util.java:219)
>>>>
>>>
>>> it seems to me that you wrote c: instead of :c ...try again with the
>>> correct key :)
>>>
>>> Jim
>>>
>>>
>>> --
>>> --
>>> 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+unsubscribe@**googlegroups.com<clojure%2bunsubscr...@googlegroups.com>
>>> 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 
>>> clojure+unsubscribe@**googlegroups.com<clojure%2bunsubscr...@googlegroups.com>
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>  --
>> --
>> 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/groups/opt_out.
>>
>>
>>
>
>  --
> --
> 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/groups/opt_out.
>
>
>

-- 
-- 
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/groups/opt_out.


<<322.gif>>

Reply via email to