Commit 7e735950 authored by David Feuer's avatar David Feuer Committed by Joachim Breitner

Make tails a good producer (#9670)

Reviewed By: nomeata, austin
Differential Revision: https://phabricator.haskell.org/D325
parent cde3a77f
......@@ -787,9 +787,12 @@ inits = map toListSB . scanl' snocSB emptySB
-- Note that 'tails' has the following strictness property:
-- @tails _|_ = _|_ : _|_@
tails :: [a] -> [[a]]
tails xs = xs : case xs of
[] -> []
_ : xs' -> tails xs'
{-# INLINABLE tails #-}
tails lst = build (\c n ->
let tailsGo xs = xs `c` case xs of
[] -> n
_ : xs' -> tailsGo xs'
in tailsGo lst)
-- | The 'subsequences' function returns the list of all subsequences of the argument.
--
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment