fun lt10(x: Int): Bool do return x < 10
var pred = <10
var xs = [1..9]
assert xs.iterator.all(pred)
assert [].iterator.all(pred)
assert not [1..10].iterator.all(pred)
# Checks if all elements respect a predicate
#
# ~~~~nitish
# fun lt10(x: Int): Bool do return x < 10
#
# var pred = <10
# var xs = [1..9]
# assert xs.iterator.all(pred)
# assert [].iterator.all(pred)
# assert not [1..10].iterator.all(pred)
# ~~~~
fun all(pred: Fun1[E,Bool]): Bool
do
for x in self do
if not pred.call(x) then
return false
end
end
return true
end
lib/functional/iter_extras.nit:109,9--128,11