Forked from anonymous/ariarule-4clojure-solution114.clj
Created
March 23, 2012 23:02
-
-
Save Ariarule/2176138 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
;; 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