A not empty array containing only the given value.
toList ( singleton "a" ) == [ "a" ]Same as Array.initialize.
Will always include at least 1 value ( initialized with index 0 ).
initialize 4 identity == fromListWithHead 0 [ 1, 2, 3 ]
initialize 4 ( \n -> n * n ) == fromListWithHead 0 [ 1, 4, 9 ]
initialize 4 ( always 0 ) == fromListWithHead 0 [ 0, 0, 0 ]
initialize 0 ( \n -> n + 4 ) == singleton 4Same as Array.repeat.
Will always include at least 1 value.
repeat 4 "Value" == fromListWithHead "Value" [ "Value", "Value", "Value" ]
repeat 0 "Test" == singleton "Test"A not empty array list with the given head and tail
array = withHead 5 ( Array.fromList [ 4, 3 ] )
toArray array == Array.fromList [ 5, 4, 3 ]
head array == 5
tail array == Array.fromList [ 4, 3 ]Same as Array.fromList except using a NotEmpty.List
Same as withHead but with a list instead of a array
Convert a regular array into a not empty array, or Nothing if the array is empty
fromArray ( Array.fromList [] ) == Nothing
fromArray ( Array.fromList [ 1, 2, 3 ] ) == Just ( fromListWithHead 1 [ 2, 3 ] )Convert a not empty array into a regular array
toArray ( fromListWithHead 1 [ 2, 3 ] ) == Array.fromList [ 1, 2, 3 ] toArray ( singleton 1 ) == Array.fromList [ 1 ]
Extract the first element from a not empty array.
head ( fromListWithHead 1 [ 2, 3 ] ) == 1
head ( singleton 1 ) == 1Extract the last element from a not empty array.
last ( fromListWithHead 1 [ 2, 3 ] ) == 3
last ( singleton 1 ) == 1Returns the elements after the first element as a regular array
tail ( fromListWithHead 1 [ 2, 3 ] ) == Array.fromList [ 2, 3 ]
tail ( singleton 1 ) == Array.fromList []Returns wether the array has a tail with elements
hasTail ( fromListWithHead 1 [ 2, 3 ] ) == True
hasTail ( singleton 1 ) == False
hasTail ( fromListWithHead 1 [] ) == FalseAppend a regular array to a not empty array
appendArray ( repeat 2 42 ) ( Array.repeat 3 81 ) == fromListWithHead 42 [ 42, 81, 81, 81 ]Prepend a regular array to a not empty array
prependArray ( Array.repeat 2 42 ) ( repeat 3 81 ) == fromListWithHead 42 [ 42, 81, 81, 81 ]Same as Array.filter but will return Nothing if no elements satisfy the test
filter isEven ( fromListWithHead 1 [ 2, 3, 4, 5, 6 ] ) == Just ( fromListWithHead 2 [ 4, 6 ] )
filter isEven ( fromListWithHead 1 [ 3, 5 ] ) == NothingSame as Array.get
Same as Array.set
Same as Array.push
Same as Array.append
Same as Array.length
Same as Array.map
Same as Array.indexedMap
Same as Array.foldl
Same as Array.foldr
Same as Array.toList
Same as Array.toIndexedList
Not empty version of
Array