feat: add Sequence.any method as complement to Sequence.all
Adds a new `any` method to the Sequence class that tests whether any element in the sequence passes the given predicate function, returning true on the first match or false if none match. Includes documentation, core library source update, and three new test files covering basic functionality, non-boolean return values, and non-function argument error handling.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user