tails package:rio

O(n) Returns all final segments of the given ByteString, longest first.
The tails function returns all final segments of the argument, longest first.

Laziness

Note that tails has the following strictness property: tails _|_ = _|_ : _|_
>>> tails undefined
[*** Exception: Prelude.undefined
>>> drop 1 (tails [undefined, 1, 2])
[[1, 2], [2], []]

Examples

>>> tails "abc"
["abc","bc","c",""]
>>> tails [1, 2, 3]
[[1,2,3],[2,3],[3],[]]
>>> tails []
[[]]
The tails function takes a stream xs and returns all the suffixes of xs, starting with the longest. The result is NonEmpty because the result always contains the empty list as the last element.
tails [1,2,3] == [1,2,3] :| [[2,3], [3], []]
tails [1] == [1] :| [[]]
tails [] == [] :| []
Returns a sequence of all suffixes of this sequence, longest first. For example,
tails (fromList "abc") = fromList [fromList "abc", fromList "bc", fromList "c", fromList ""]
Evaluating the <math>th suffix takes <math>, but evaluating every suffix in the sequence takes <math> due to sharing.
O(n) Return all final segments of the given Text, longest first.
O(n) Returns all final segments of the given ByteString, longest first.