init -package:relude

Return all the elements of a list except the last one. The list must be non-empty. WARNING: This function is partial. Consider using unsnoc instead.

Examples

>>> init [1, 2, 3]
[1,2]
>>> init [1]
[]
>>> init []
*** Exception: Prelude.init: empty list
Extract everything except the last element of the stream.
O(1) Returns all the elements of a ByteString except the last one. An exception will be thrown in the case of an empty ByteString. This is a partial function, consider using unsnoc instead.
O(n/c) Returns all the elements of a ByteString except the last one. This is a partial function, consider using unsnoc instead.
O(n) Return all the elements of a ShortByteString except the last one. An exception will be thrown in the case of an empty ShortByteString. This is a partial function, consider using unsnoc instead. Note: copies the entire byte array
O(1) Returns all but the last character of a Text, which must be non-empty. This is a partial function, consider using unsnoc instead.
O(1) Returns all but the last character of a Stream Char, which must be non-empty. Properties
unstream . init . stream = init
O(n/c) Returns all but the last character of a Text, which must be non-empty. This is a partial function, consider using unsnoc instead.
Call hc-pkg to initialise a package database at the location {path}.
hc-pkg init {path}
Return all the elements of a list except the last one. The list must be non-empty.
>>> init [1, 2, 3]
[1,2]

>>> init [1]
[]

>>> init []
*** Exception: Prelude.init: empty list
WARNING: This function is partial. You can use reverse with case-matching or uncons instead.
init a context
init a context
O(n/c) Return all the elements of a ByteString except the last one.
O(1) Return all the elements of a ByteString except the last one. An exception will be thrown in the case of an empty ByteString.
Return all the elements of a list except the last one. The list must be non-empty.
O(n/c) Returns all but the last character of a Text, which must be non-empty. Subject to fusion.
O(1) Returns all but the last character of a Text, which must be non-empty. Subject to fusion.
O(1) Yield all but the last element without copying. The vector may not be empty.
O(1) Yield all but the last element without copying. The vector may not be empty.
O(1) Yield all but the last element without copying. The vector may not be empty.
O(1) Yield all but the last element without copying. The vector may not be empty.
Safe version of initEx, only working on non-nullable sequences.
Return all the elements of a list except the last one. The list must be non-empty.
>>> init [1, 2, 3]
[1,2]

>>> init [1]
[]

>>> init []
*** Exception: Prelude.init: empty list
Drop last character from non-empty ShortText.
>>> tail "abcd"
"bcd"
Note: Will throw an error exception for empty ShortTexts. Consider using the total functions unsnoc or dropEnd instead.