Skip to content

Instantly share code, notes, and snippets.

@kindlychung
Created January 13, 2015 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kindlychung/a65bdf1cb4b0ef598d64 to your computer and use it in GitHub Desktop.
Save kindlychung/a65bdf1cb4b0ef598d64 to your computer and use it in GitHub Desktop.
(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