Last active
August 29, 2015 14:06
-
-
Save dagda1/9f6a503a8e35cb8006aa 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
(= (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