Seq processing until true function is true

I process the sequence in clojure. I would like to get the elements until the predicate function is true. How to do it?

+6
source share
1 answer

You can use take-while along with not

 user=> (take-while (comp not even?) [3 9 2 4 6 10 1 2]) (3 9) 
+6
source

Source: https://habr.com/ru/post/919649/


All Articles