Ok, but apparently I'm not the only one to be puzzled by this behaviour, 
which we may regard as an inconsistency.
Just to know, is it planned to be changed? (so that I can note it and 
remember it if I have an error that appears in this part of my code after a 
clojure upgrade)

Le mardi 14 janvier 2014 18:20:45 UTC+1, Filip Štaffa a écrit :
>
> Hi Yves,
>
> I guess it is because r/reduce calls r/reduce-kv (which is specific for 
> map), while r/fold it does not have such special handling
>
> Filip
>
> On Tuesday, January 14, 2014 4:43:10 PM UTC+1, Yves Parès wrote:
>>
>> Hello!
>> When mapping and reducing a map, it seems arguments are passed 
>> differently to the function that is mapped depending on whether you reduce 
>> with r/reduce or r/fold:
>>
>> (r/fold +
>>     (r/map (fn [k v] (inc v)) {:a 4 :b 5}))
>> But:
>> (r/reduce +
>>     (r/map (fn [[k v]] (inc v)) {:a 4 :b 5}))
>>
>> The function r/mapped is the same each time, but if the return value of 
>> r/map is further reduce with r/fold, it received 2 arguments (key and 
>> value). However, if it is reduced with r/reduce, the fn is called with ONE 
>> pair [k v].
>>
>> Is that normal?
>>
>

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