module Algorithms.List.BasicOperations.Inits where
import Algorithms.List.BasicOperations.TakeWhile
inits
is a function that returns all substrings of the list in succession from the beginning[^1].
-- | >>> inits "abc"
-- ["","a","ab","abc"]
inits :: [a] -> [[a]]
inits = takeWhileCataM (const [False, True])
tails
is a function that enumerates all contiguous partial lists from the end of a given list[^1].
-- | >>> tails "abc"
-- ["abc","bc","c",""]
tails :: [a] -> [[a]]
tails = dropWhileParaM (const [False, True])