The Warrior — Arrays/Lists
List manipulation, access, modification
Create a new list from items.
ayanmo list = Ogunda.create(1, 2, 3, 4, 5);
// Or use literal: [1, 2, 3, 4, 5]
Get list length.
ayanmo items = [1, 2, 3];
Irosu.fo(Ogunda.len(items)); // 3
Add item to end of list (returns new list).
ayanmo list = [1, 2, 3];
ayanmo list = Ogunda.push(list, 4);
// list is now [1, 2, 3, 4]
Remove and return last item.
ayanmo list = [1, 2, 3];
ayanmo last = Ogunda.pop(list); // 3
Get first element.
ayanmo first = Ogunda.first([10, 20, 30]); // 10
Get last element.
ayanmo last = Ogunda.last([10, 20, 30]); // 30
Get element at index.
ayanmo items = ["a", "b", "c"];
Irosu.fo(Ogunda.get(items, 1)); // "b"
Check if list contains item.
ayanmo has_it = Ogunda.contains([1, 2, 3], 2); // otito
Reverse list order.
ayanmo reversed = Ogunda.reverse([1, 2, 3]); // [3, 2, 1]
Get sublist from start to end.
ayanmo items = [1, 2, 3, 4, 5];
ayanmo sub = Ogunda.slice(items, 1, 4); // [2, 3, 4]