Try Install Learn Blog API Packages GitHub
Pages
array-extra

Search
Basic information
Entities
Versions
Dependencies
mint-core 0.0.0 <= v < 1.0.0

Array.Extra

Functions

append
(
array1
:
Array(a)
array2
:
Array(a)
)
:
Array(a)

Put two lists together:

Array.Extra.append([1,1,2] [3,5,8]) == [1,1,2,3,5,8]
concat
(
arrays
:
Array(Array(a))
)
:
Array(a)

Concatenate a bunch of arrays into a single array:

Array.Extra.concat([[1,2],[3],[4,5]]) == [1,2,3,4,5]
drop
(
number
:
Number
array
:
Array(a)
)
:
Array(a)

Drop n number of items from the left

Array.Extra.drop(2, [1,2,3,4]) == [3,4]
flatMap
(
func
:
Function(a, Array(b))
array
:
Array(a)
)
:
Array(b)

Map over a nested array and then flatten:

[[1,2],[1,5]]
Array.Extra.flatMap((a : Array(Number) : Array(Number) => { [Array.max(n)] }) == [2,5]
foldl
(
func
:
Function(a, b, b)
initial
:
b
array
:
Array(a)
)
:
b

Reduce a list from the left.

Array.Extra.foldl((acc : Number, n : Number) : Number => { acc + n}, 0, [1,2,3,4,5]) == 15
foldr
(
func
:
Function(a, b, b)
initial
:
b
array
:
Array(a)
)
:
b

Reduce a list from the right.

Array.Extra.foldr((acc : Number, n : Number) : Number => { acc + n}, 0, [1,2,3,4,5]) == 15
groupsOf
(
number
:
Number
array
:
Array(a)
)
:
Array(Array(a))

Group an array into sub groups of specified length (all items are included so the last group maybe shorter if after grouping there is a remainder)

Array.Extra.groupsOf(2, [1,2,3,4,5,6,7]) == [[1,2],[3,4],[5,6],[7]]
take
(
number
:
Number
array
:
Array(a)
)
:
Array(a)

Take n number of items from the left

Array.Extra.take(2, [1,2,3,4]) == [1,2]