Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

processing a seq until a pred function is true

I am processing a sequence in clojure. I would like to retrieve elements until a predicate function is true. How do I do that?

like image 266
murtaza52 Avatar asked Jul 04 '12 06:07

murtaza52


1 Answers

You can use take-while along with not

user=> (take-while (comp not even?) [3 9 2 4 6 10 1 2])
(3 9)
like image 65
Ankur Avatar answered Oct 04 '22 16:10

Ankur