-
-
Save kindlychung/a65bdf1cb4b0ef598d64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn my-reduce | |
([f initial coll] | |
(loop [result initial | |
remaining coll | |
] | |
(let [[currect & rest] remaining] | |
(if (empty? remaining) | |
result | |
(recur (f result current) rest) | |
)) | |
) | |
) | |
;([f [head & tail]] | |
; (my-reduce f (f head (first tail)) (rest tail)) | |
; ) | |
) | |
(my-reduce + 1 [1 2 3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment