inits package:containers

Returns a sequence of all prefixes of this sequence, shortest first. For example,
inits (fromList "abc") = fromList [fromList "", fromList "a", fromList "ab", fromList "abc"]
Evaluating the <math>th prefix takes <math>, but evaluating every prefix in the sequence takes <math> due to sharing.