mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
Added arrayFind
This commit is contained in:
parent
9e5c562d60
commit
11203f3a85
4 changed files with 16 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue