2023-11-28 16:38:40 +00:00
|
|
|
find = |items <list> function <fn>| <any> {
|
|
|
|
for i in items {
|
2023-11-16 06:59:48 +00:00
|
|
|
if (function i) {
|
|
|
|
return i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-28 16:38:40 +00:00
|
|
|
map = |items <list> function <fn>| <list> {
|
2023-11-16 06:59:48 +00:00
|
|
|
new_list = []
|
|
|
|
|
2023-11-28 16:38:40 +00:00
|
|
|
for i in items {
|
2023-11-16 06:59:48 +00:00
|
|
|
new_list += (function i)
|
|
|
|
}
|
|
|
|
|
|
|
|
new_list
|
|
|
|
}
|
|
|
|
|
2023-11-28 16:38:40 +00:00
|
|
|
foobar <int> = [0 1 2]
|
|
|
|
-> (map |i <int>| <int> { i - 1 })
|
|
|
|
-> (find |i <int>| <bool> { i == -1 })
|
|
|
|
|
|
|
|
foobar
|