Mutable List
unary
last or panic, use lastOrNull for safety
Immutable list, elemets will be shadow copied
Mutable list, elemets will be shadow copied
Like in Solitaire
All processing methods like filter map, will execute lazy
{1 2 3} sum == 6
keyword
{1 2 3} forEachIndexed: [i, it -> "$i element is $it" echo ]
like list[x] in C, can panic
safe version of at
{1 2 3} contains: 1 is true
Returns a list containing all elements except first n elements
Returns a list containing all elements except last n elements.
Splits this collection into a list of lists each not exceeding the given size
{1 2 3} joinWith: ", " is 1, 2, 3
Usable for joining fields of objects without unpacking them, elements joining with ", "
For sorting collection of objects by one of their field
Same as joinToString, but you can choose how to join(not only ", ")
Accumulates value starting with injected value and applying operation from left to right to current accumulator value and each element(kinda fold) {1 2 3} inject: 0 into: [acc, next -> acc + next] // is 6
Accumulates value starting with the first element and applying operation from left to right to current accumulator value and each elementsame as inject:into: but without accumulator arg
Splits the original collection into pair of lists, where first list contains elements for which predicate yielded true, while second list contains elements for which predicate yielded false. {1 2 3 4} partition: [it % 2 == 0] // {[2, 4], [1, 3]}
Returns the first element matching the given predicate, or null if no such element was found.
Returns a view of the portion of this list between the specified fromIndex (inclusive) and toIndex (exclusive). The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa.
Add all items from other collection
Remove element by index
Remove element
like C arr[x] = y