Roelof, The function you're passing to reduce still wants to accept two arguments. See the documentation: https://clojuredocs.org/clojure.core/reduce
Take care, Moe On Sun, Oct 4, 2015 at 8:40 AM, Roelof Wobben <wobbenroe...@gmail.com> wrote: > Oke, then I hve to find out where to put the initial value. > > These two do not work : > > (reduce (fn [counter] (inc counter)) 0 [1,2,3]) > (reduce (fn [counter] (inc counter) 0 ) [1,2,3]) > > Op zaterdag 3 oktober 2015 23:34:20 UTC+2 schreef Moe Aboulkheir: >> >> Roelof, >> >> Unless supplied with an initial value, reduce will use the first value >> from the collection you supply - every sequence which doesn't start with >> "1" will give you the wrong answer. >> >> Take care, >> Moe >> >> On Sat, Oct 3, 2015 at 9:40 PM, Roelof Wobben <wobben...@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 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/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. > -- 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.