Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(defn numbered-line? [s]
(Character/isDigit (first s)))
(defn split-group [lines]
(when (seq lines)
(let [[group remaining] (split-with (complement numbered-line?) (next lines))]
[(cons (first lines) group)
(defn groups [lines]
(->> [nil lines]
(iterate (comp split-group second))
(map first)
(take-while identity)))
(comment> (groups ["1. foo" "bar" "baz" "2. bing" "bang" "bong" "3. eouaeo" "ueoue"])
(("1. foo" "bar" "baz") ("2. bing" "bang" "bong") ("3. eouaeo" "ueoue")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.