fun eq10(x: Int): Bool do return x == 10
var pred = &eq10
var xs = [1,2,5,7,9,10,44]
assert xs.iterator.any(pred)
var ys = []
assert not ys.iterator.any(pred)
assert not [1,2,44].iterator.any(pred)
# Checks if at least one element respects a predicate
#
# ~~~~nitish
# fun eq10(x: Int): Bool do return x == 10
#
# var pred = &eq10
# var xs = [1,2,5,7,9,10,44]
# assert xs.iterator.any(pred)
# var ys = []
# assert not ys.iterator.any(pred)
# assert not [1,2,44].iterator.any(pred)
# ~~~~
fun any(pred: Fun1[E,Bool]): Bool
do
for x in self do
if pred.call(x) then
return true
end
end
return false
end
lib/functional/iter_extras.nit:87,9--107,11