Reduce can take either two or three arguments; when it takes two arguments,
it makes some assumptions about the argument that was left out. You're
using reduce with two arguments, so you might want to rethink those
assumptions.

On Sat, Oct 3, 2015 at 2:19 PM Roelof Wobben <wobbenroe...@gmail.com> wrote:

> Hello,
>
> I have to make a function which counts a collection without using count.
>
> So I came up with this :
>
> (fn [coll]  (reduce (fn [counter _ ] (inc counter)) coll)))
>
> it works well with coll is [ 1 2 3]
>
> but it fails with "Hello World"
>
> How can I improve my code to work in both cases.
>
> Please , do not only give the answer but rather explain how I can make
> this work.
> So I learn a lot and not do only a copy/paste.
>
> Roelof
>
> --
> 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.

Reply via email to