Ògúndá 1110

The Warrior — Arrays/Lists

List manipulation, access, modification

Methods

create / da / new

Ogunda.create(items...) ? List

Create a new list from items.

ayanmo list = Ogunda.create(1, 2, 3, 4, 5);
// Or use literal: [1, 2, 3, 4, 5]

len / gigun

Ogunda.len(list: List) ? Int

Get list length.

ayanmo items = [1, 2, 3];
Irosu.fo(Ogunda.len(items));  // 3

push / fikun / append

Ogunda.push(list: List, item) ? List

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]

pop / y?

Ogunda.pop(list: List) ? Any

Remove and return last item.

ayanmo list = [1, 2, 3];
ayanmo last = Ogunda.pop(list);  // 3

first / ak?k?

Ogunda.first(list: List) ? Any

Get first element.

ayanmo first = Ogunda.first([10, 20, 30]);  // 10

last / ik?hin

Ogunda.last(list: List) ? Any

Get last element.

ayanmo last = Ogunda.last([10, 20, 30]);  // 30

get / gba

Ogunda.get(list: List, index: Int) ? Any

Get element at index.

ayanmo items = ["a", "b", "c"];
Irosu.fo(Ogunda.get(items, 1));  // "b"

contains / ni

Ogunda.contains(list: List, item) ? Bool

Check if list contains item.

ayanmo has_it = Ogunda.contains([1, 2, 3], 2);  // otito

reverse / yipada

Ogunda.reverse(list: List) ? List

Reverse list order.

ayanmo reversed = Ogunda.reverse([1, 2, 3]);  // [3, 2, 1]

slice / ge

Ogunda.slice(list: List, start: Int, [end: Int]) ? List

Get sublist from start to end.

ayanmo items = [1, 2, 3, 4, 5];
ayanmo sub = Ogunda.slice(items, 1, 4);  // [2, 3, 4]