Skip to content

Instantly share code, notes, and snippets.

@gfredericks
Created August 24, 2010 00:17
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 gfredericks/546627 to your computer and use it in GitHub Desktop.
Save gfredericks/546627 to your computer and use it in GitHub Desktop.
(defn- my-split-at
"A reimplementation of clojure.core/split-at that doesn't
compute the sequence twice."
[n coll]
(loop [nn n l [] r coll]
(if (or (zero? nn) (empty? r))
[l r]
(let [[rx & rs] r]
(recur
(dec nn)
(conj l rx)
rs)))))
(defn- my-next-val
[m]
(if (< (:a m) 1000000)
(assoc m :a (inc (:a m)))))
(defn process-from-ob
[]
(loop [the-seq (take-while identity (iterate my-next-val {:a 1598})) results []]
(let [[first-part rest-part] (my-split-at 30 the-seq)
new-results (into [] (filter (fn [_] false) first-part))]
(let [concatted (concat results new-results)]
(if (empty? rest-part)
{:results (map str concatted),
:next (first rest-part)}
(recur rest-part concatted))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment