Re: using -> on a nested hash-map with string keywords.

2012-06-01 Thread Sean Corfield
On Fri, Jun 1, 2012 at 12:08 AM, Boris V. Schmid  wrote:
> Thanks, it was get-in that I was looking for, but couldn't find.

At this point I'll give a plug for http://clojureatlas.com as a great
way to explore the Clojure core/libraries by concept.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

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


Re: using -> on a nested hash-map with string keywords.

2012-06-01 Thread Boris V. Schmid
Thanks, it was get-in that I was looking for, but couldn't find. Also 
thanks to Dave for explaining that keywords have some internal magic 
compared to strings. will remember!

On Thursday, 31 May 2012 19:22:50 UTC+2, Alan Malloy wrote:
>
> Yes, but really to GET a value nested IN a series of maps, he should 
> just be using get-in, rather than threading anything at all. 
>
> On May 31, 7:59 am, Dave Ray  wrote: 
> > Keywords implement IFn meaning they can act as functions that look 
> > themselves up in a map. Strings are just strings. Replace "b" with 
> > (get "b") and you'll get the behavior you're looking for. 
> > 
> > Dave 
> > 
> > On Thu, May 31, 2012 at 7:55 AM, Boris V. Schmid  
> wrote: 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > Can someone tell me what I'm overlooking (clojure 1.4) 
> > 
> > > (-> (hash-map :b (hash-map :a 3)) :b :a) 
> > > 3 
> > > user> (-> (hash-map "b" (hash-map :a 3)) "b" :a) 
> > > ; Evaluation aborted: java.lang.String cannot be cast to 
> clojure.lang.IFn 
> > 
> > > I'm not sure why the first can work, and the second cannot. Is it a 
> logical 
> > > limitation of the language, or an oversight in how the macro -> is 
> build? 
> > 
> > > -- 
> > > 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 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

Re: using -> on a nested hash-map with string keywords.

2012-05-31 Thread Dave Ray
Too true.

On Thu, May 31, 2012 at 10:22 AM, Alan Malloy  wrote:
> Yes, but really to GET a value nested IN a series of maps, he should
> just be using get-in, rather than threading anything at all.
>
> On May 31, 7:59 am, Dave Ray  wrote:
>> Keywords implement IFn meaning they can act as functions that look
>> themselves up in a map. Strings are just strings. Replace "b" with
>> (get "b") and you'll get the behavior you're looking for.
>>
>> Dave
>>
>> On Thu, May 31, 2012 at 7:55 AM, Boris V. Schmid  
>> wrote:
>>
>>
>>
>>
>>
>>
>>
>> > Can someone tell me what I'm overlooking (clojure 1.4)
>>
>> > (-> (hash-map :b (hash-map :a 3)) :b :a)
>> > 3
>> > user> (-> (hash-map "b" (hash-map :a 3)) "b" :a)
>> > ; Evaluation aborted: java.lang.String cannot be cast to clojure.lang.IFn
>>
>> > I'm not sure why the first can work, and the second cannot. Is it a logical
>> > limitation of the language, or an oversight in how the macro -> is build?
>>
>> > --
>> > 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 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 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


Re: using -> on a nested hash-map with string keywords.

2012-05-31 Thread Alan Malloy
Yes, but really to GET a value nested IN a series of maps, he should
just be using get-in, rather than threading anything at all.

On May 31, 7:59 am, Dave Ray  wrote:
> Keywords implement IFn meaning they can act as functions that look
> themselves up in a map. Strings are just strings. Replace "b" with
> (get "b") and you'll get the behavior you're looking for.
>
> Dave
>
> On Thu, May 31, 2012 at 7:55 AM, Boris V. Schmid  
> wrote:
>
>
>
>
>
>
>
> > Can someone tell me what I'm overlooking (clojure 1.4)
>
> > (-> (hash-map :b (hash-map :a 3)) :b :a)
> > 3
> > user> (-> (hash-map "b" (hash-map :a 3)) "b" :a)
> > ; Evaluation aborted: java.lang.String cannot be cast to clojure.lang.IFn
>
> > I'm not sure why the first can work, and the second cannot. Is it a logical
> > limitation of the language, or an oversight in how the macro -> is build?
>
> > --
> > 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 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


Re: using -> on a nested hash-map with string keywords.

2012-05-31 Thread Jay Fields
(:b {:b 1}) => 1
("b" {"b" 1}) => same error.

If you want that to work, you need something that creates ({"b" 1} "b") or
(get {"b" 1} "b")

for your example, I believe this works
(-> (hash-map "b" (hash-map :a 3)) (get "b") :a)

Cheers, Jay

On Thu, May 31, 2012 at 10:55 AM, Boris V. Schmid wrote:

> Can someone tell me what I'm overlooking (clojure 1.4)
>
> (-> (hash-map :b (hash-map :a 3)) :b :a)
> 3
> user> (-> (hash-map "b" (hash-map :a 3)) "b" :a)
> ; Evaluation aborted: java.lang.String cannot be cast to clojure.lang.IFn
>
> I'm not sure why the first can work, and the second cannot. Is it a
> logical limitation of the language, or an oversight in how the macro -> is
> build?
>
>  --
> 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 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

Re: using -> on a nested hash-map with string keywords.

2012-05-31 Thread Dave Ray
Keywords implement IFn meaning they can act as functions that look
themselves up in a map. Strings are just strings. Replace "b" with
(get "b") and you'll get the behavior you're looking for.

Dave

On Thu, May 31, 2012 at 7:55 AM, Boris V. Schmid  wrote:
> Can someone tell me what I'm overlooking (clojure 1.4)
>
> (-> (hash-map :b (hash-map :a 3)) :b :a)
> 3
> user> (-> (hash-map "b" (hash-map :a 3)) "b" :a)
> ; Evaluation aborted: java.lang.String cannot be cast to clojure.lang.IFn
>
> I'm not sure why the first can work, and the second cannot. Is it a logical
> limitation of the language, or an oversight in how the macro -> is build?
>
> --
> 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 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