Created
November 4, 2009 23:57
-
-
Save ato/226530 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 esj-problem | |
[n limit s] | |
(if-not (seq s) ; reached end of input? | |
(when-not (zero? n) ; if there's anything left-over return it | |
(list n)) | |
(if (>= n limit) ; have we reached the limit? | |
(lazy-seq ; if so, spit out a new output | |
(cons n (esj-problem 0 limit s))) | |
; haven't reached limit, gobble some more input | |
(recur (+ n (first s)) limit (next s))))) | |
(esj-problem 0 10 [1 4 8 73 2 4 1 8 9]) | |
# => (13 73 15 9) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment