(defn my-reduce
([f initial coll]
(loop [result initial
diff --git a/content/cftbat/do-things.html b/content/cftbat/do-things.html index f027ae3b..7845ce06 100644 --- a/content/cftbat/do-things.html +++ b/content/cftbat/do-things.html @@ -1070,7 +1070,7 @@
If you provide an initial value, reduce starts by applying the given function to the initial value and the first element of the sequence rather than the first two elements of the sequence.
One detail to note is that, in these examples, reduce takes a collection of elements, [1 2 3 4], and returns a single number. Although programmers often use reduce this way, you can also use reduce to return an even larger collection than the one you started with, as we’re trying to do with symmetrize-body-parts. reduce abstracts the task “process a collection and build a result,” which is agnostic about the type of result returned. To further understand how reduce works, here’s one way that you could implement it:
One detail to note is that, in these examples, reduce takes a collection of elements, [1 2 3 4], and returns a single number. Although programmers often use reduce this way, you can also use reduce to return an even larger collection than the one you started with, as we’re trying to do with symmetrize-body-parts. reduce abstracts the task “process a collection and build a result,” which is agnostic about the type of result returned. To further understand how reduce works, here’s one way that you could implement it:
(defn my-reduce
([f initial coll]
(loop [result initial