List functions

# Name Description Complexity
1 getElement(List[T], Int): T Gets the element by index 2
2 cons(T, List[T]): List[T] Inserts the element at the beginning of the list 2
3 size(List[T]): Int Returns the size of the list 2

getElement(List[T], Int): T

Gets the element by index.

getElement(arr: List[T], pos: Int): T

Parameters

arr: List[T]

List.

pos: Int

Index of the element.

cons(T, List[T]): List[T]

Inserts the element at the beginning of the list.

cons(head:T, tail: List[T]): List[T]

Parameters

head: T

Element.

tail: List[T]

List.

size(List[T]): Int

Returns the size of the list.

size(arr: List[T]): Int

Parameters

arr: List[T]

List.

results matching ""

    No results matching ""