dust/std/list.ds

30 lines
408 B
Plaintext
Raw Normal View History

2023-12-12 23:21:16 +00:00
contains <([any], any) -> bool> = fn |list, target| {
for item in list {
if item == target {
return true;
}
}
false
}
find <([any], any) -> bool> = fn |list, target| {
for item in list {
if item == target {
return item;
}
}
}
reverse <([any]) -> [any]> = fn |list| {
new_list = []
index = (length list) - 1;
while index >= 0 {
new_list += list:index
index -= 1
}
new_list
}