Added Sequence.any as complement to Sequence.all

This commit is contained in:
Thorbjørn Lindeijer
2015-03-01 23:14:32 +01:00
parent e72eedc6f5
commit 8f985847d4
6 changed files with 40 additions and 2 deletions
+7
View File
@@ -22,6 +22,13 @@ class Sequence {
return true
}
any(f) {
for (element in this) {
if (f.call(element)) return true
}
return false
}
reduce(acc, f) {
for (element in this) {
acc = f.call(acc, element)