Skip to content

Instantly share code, notes, and snippets.

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 Ariarule/2176138 to your computer and use it in GitHub Desktop.
Save Ariarule/2176138 to your computer and use it in GitHub Desktop.
;; ariarule's solution to Global take-while
;; https://4clojure.com/problem/114
(fn [n p s]
(take (dec (count (take-while #(< % n)
(reduce #(let [n (if %2
(inc (last %1))
(last %))]
(conj %1 n))
[0]
(map p s))))) s))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment