Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mecdemort
Created April 14, 2011 16:57
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 mecdemort/919923 to your computer and use it in GitHub Desktop.
Save mecdemort/919923 to your computer and use it in GitHub Desktop.
(defn reduce-to [n coll]
(lazy-loop [[f & r :as s] (rest coll)
c (first coll)]
(if f
(if (< c n)
(lazy-recur r (+ c f))
(cons c (reduce-to n s)))
(when c [c]))))
(defn reduce-to [n coll]
(lazy-seq
(loop [[f & r :as s] (rest coll)
c (first coll)]
(if f
(if (< c n)
(recur r (+ c f))
(cons c (reduce-to n s)))
(when c [c])))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment