Created
August 24, 2010 00:17
-
-
Save gfredericks/546627 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
(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