Skip to content

Instantly share code, notes, and snippets.

Created March 23, 2012 22:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/2175965 to your computer and use it in GitHub Desktop.
Save anonymous/2175965 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