user> (class (keys {:a 0 :b 1}))
clojure.lang.APersistentMap$KeySeq

Are you sure PersistentMap$KeySeq is lazy? I don't really get how a lazy 
sequence over an associative would work in Clojure (at least as clojure 
exists now).

Pardon my ignorance but if this is producing a lazy result, how is it doing 
so?
https://github.com/clojure/clojure/blob/dff9600387b962f16fc78e6477e10e34651fd366/src/jvm/clojure/lang/APersistentMap.java#L134

On Saturday, February 1, 2014 7:54:32 PM UTC-8, Ambrose Bonnaire-Sergeant 
wrote:
>
> zipmap could also potentially use transients (which would be a nice 
> addition).
>
> keys/vals are also lazy, so I would be surprised if there was any 
> performance
> difference with walking the seq "twice".
>
> Thanks,
> Ambrose
>
> On Sun, Feb 2, 2014 at 11:35 AM, Justin Smith <noise...@gmail.com<javascript:>
> > wrote:
>
>> Realistically, how many situations are there where running keys and vals 
>> independently is preferable to running seq once and using the two element 
>> vectors that returns?
>>
>> Usually this way one can avoid walking the whole thing twice.
>>
>> (into {} (map (fn [[k v]] [k (inc v)]) {:a 0 :b 1})) is representative of 
>> the idiom I usually use. As a bonus, into uses transients, which can create 
>> the resulting structure in fewer cycles / less time.
>>
>>
>> On Saturday, February 1, 2014 10:00:33 AM UTC-8, Sam Ritchie wrote:
>>
>>> Looks like Rich just chimed in with:
>>>
>>> "keys order == vals order == seq order "
>>>
>>>   Matching Socks
>>>  January 31, 2014 7:31 PM
>>> Actually, http://dev.clojure.org/jira/browse/CLJ-1302 "keys and vals 
>>> consistency not mentioned in docstring" was declined, with the comment "The 
>>> absence of this property in the docs is correct. You should not rely on 
>>> this."
>>>
>>>
>>>
>>> On Wednesday, August 11, 2010 6:03:39 PM UTC-4, Chouser wrote:
>>> -- 
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>
>>> -- 
>>> Sam Ritchie (@sritchie)
>>>  Paddleguru Co-Founder
>>> 703.863.8561
>>> www.paddleguru.com
>>> Twitter <http://twitter.com/paddleguru> // 
>>> Facebook<http://facebook.com/paddleguru>
>>>  
>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com<javascript:>
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com <javascript:>
>> 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+u...@googlegroups.com <javascript:>.
>> 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.

Reply via email to