Skip to content

Instantly share code, notes, and snippets.

@dagda1
Last active August 29, 2015 14:06
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 dagda1/9f6a503a8e35cb8006aa to your computer and use it in GitHub Desktop.
Save dagda1/9f6a503a8e35cb8006aa to your computer and use it in GitHub Desktop.
(= (take 5 (
(fn my-reduct
([func coll]
(my-reduct func (first coll) (rest coll)))
([func firstArg coll]
(letfn [(reduct [f init se]
(lazy-seq (when-not (empty? se)
(let [res (f init (first se))]
(cons res (reduct f res (rest se)))))))]
(lazy-seq (cons firstArg (reduct func firstArg coll))))))
+ (range))) [0 1 3 6 10])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment