tail package:base-compat

Extract the possibly-empty tail of the stream.
Extract the elements after the head of a list, which must be non-empty.
>>> tail [1, 2, 3]
[2,3]

>>> tail [1]
[]

>>> tail []
*** Exception: Prelude.tail: empty list
WARNING: This function is partial. You can use case-matching or uncons instead.
The tails1 function returns all non-empty final segments of the argument, longest first.

Laziness

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

Examples

>>> tails1 "abc"
['a' :| "bc",'b' :| "c",'c' :| ""]
>>> tails1 [1, 2, 3]
[1 :| [2,3],2 :| [3],3 :| []]
>>> tails1 []
[]
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 [] == [] :| []
The tails1 function takes a NonEmpty stream xs and returns all the non-empty suffixes of xs, starting with the longest.
tails1 (1 :| [2,3]) == (1 :| [2,3]) :| [2 :| [3], 3 :| []]
tails1 (1 :| []) == (1 :| []) :| []