Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn- split-lines
- "Takes a sequence of content chunks and returns a lazy sequence of individual lines.
- (\"abc\" \"de\\nabc\") becomes (\"abcde\" \"abc\")"
- [stream]
- (let [
- chunk (first stream)
- remainder (rest stream)
- [line leftover] (string/split chunk #"\n+" 2)]
- (if leftover
- (lazy-seq (cons line (split-lines (cons leftover remainder))))
- (recur (cons
- (string/join "" (cons line (first remainder)))
- (rest remainder))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement