Clojure Programming/Examples/API Examples/Predicate functions

drop-whileEdit

user=> (drop-while pos? [1 2 3 -1 -2 3 4])
(-1 -2 3 4)

filterEdit

user=> (filter nil? [:a :b nil nil :a]) 
(nil nil)
user=> (filter (fn[x](= x :b)) [:a :b nil nil :a]) 
(:b)

not-any?Edit

user=> (not-any? neg? [1 2 3 4 5])
true
user=> (not-any? neg? [1 2 3 -4 5])
false

removeEdit

user=> (remove nil? [:a :b nil nil :a]) 
(:a :b :a)

every?Edit

user=> (every? pos? [1 2 3 4])
true
user=> (every? pos? [0 1 2 3])
false

someEdit

user=> (some neg? [0 1 2 -3 4])
true
user=> (some #{:gamma} [:professor :gamma])
:gamma
Last modified on 5 July 2010, at 07:15