-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Hi,
I don't know whether here is the correct place to ask my question, so forgive me if i break some code of conduct, please.
Also I enjoyed reading the free(!) version of your book very much so far. Thank you very much for this wonderful resource.
When encountering "reduce" I am lost and can't wrap my head around it.
(defn my-reduce
([f initial coll]
(loop [result initial
remaining coll]
(if (empty? remaining)
result
(recur (f result (first remaining)) (rest remaining)))))
([f [head & tail]]
(my-reduce f head tail)))
this part here is the beginning of the end of my understanding. Is there additional resources somewhere to somehow grasp the idea? Or should I leave it be, since it is so early in the book? Thank you very much for any response!
EDIT:
Is this part
([f initial coll]
(loop [result initial
remaining coll]
(if (empty? remaining)
result
(recur (f result (first remaining)) (rest remaining)))))
the argument to my-reduce?
Because up until now we only had arguments in "[]" following a function name. Here the part where i expected an open square bracket indeed starst with a "(".
EDIT II:
I should have read the preceding part more thoroughly. Function overloading ist the answer. Sorry for the fuzz.