24 lines
334 B
Plaintext
24 lines
334 B
Plaintext
find = |items <list> function <fn>| <any> {
|
|
for i in items {
|
|
if (function i) {
|
|
return i
|
|
}
|
|
}
|
|
}
|
|
|
|
map = |items <list> function <fn>| <list> {
|
|
new_list = []
|
|
|
|
for i in items {
|
|
new_list += (function i)
|
|
}
|
|
|
|
new_list
|
|
}
|
|
|
|
foobar <int> = [0 1 2]
|
|
-> (map |i <int>| <int> { i - 1 })
|
|
-> (find |i <int>| <bool> { i == -1 })
|
|
|
|
foobar
|