Added arrayFind

This commit is contained in:
Dmitry Boulytchev 2021-08-31 01:47:49 +03:00
parent 9e5c562d60
commit 11203f3a85
4 changed files with 16 additions and 1 deletions

View file

@ -78,3 +78,14 @@ public fun iteriArray (f, a) {
f (i, a [i])
od
}
public fun findArray (f, a) {
var i = 0, found = false, value;
while i < a.length && found == false
do
found := f (value := a[i])
od;
if found then Some (value) else None fi
}