dust/std/list_functions.ds

24 lines
334 B
Plaintext
Raw Normal View History

2023-11-28 16:38:40 +00:00
find = |items <list> function <fn>| <any> {
for i in items {
if (function i) {
return i
}
}
}
2023-11-28 16:38:40 +00:00
map = |items <list> function <fn>| <list> {
new_list = []
2023-11-28 16:38:40 +00:00
for i in items {
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