Converted from darcs patches from Bas van Dijk <v.dijk.bas@gmail.com>
Previously: tails _|_ = _|_
Now: tails _|_ = _|_ : _|_
Previously: inits _|_ = _|_
Now: inits _|_ = [] : _|_
--
-- > inits "abc" == ["","a","ab","abc"]
--
--
-- > inits "abc" == ["","a","ab","abc"]
--
+-- Note that 'inits' has the following strictness property:
+-- @inits _|_ = [] : _|_@
-inits [] = [[]]
-inits (x:xs) = [[]] ++ map (x:) (inits xs)
+inits xs = [] : case xs of
+ [] -> []
+ x : xs' -> map (x :) (inits xs')
-- | The 'tails' function returns all final segments of the argument,
-- longest first. For example,
--
-- > tails "abc" == ["abc", "bc", "c",""]
--
-- | The 'tails' function returns all final segments of the argument,
-- longest first. For example,
--
-- > tails "abc" == ["abc", "bc", "c",""]
--
+-- Note that 'tails' has the following strictness property:
+-- @tails _|_ = _|_ : _|_@
-tails [] = [[]]
-tails xxs@(_:xs) = xxs : tails xs
-
+tails xs = xs : case xs of
+ [] -> []
+ _ : xs' -> tails xs'
-- | The 'subsequences' function returns the list of all subsequences of the argument.
--
-- | The 'subsequences' function returns the list of all subsequences of the argument.
--