inits is too strict
apfelmus
apfelmus at quantentunnel.de
Wed Jun 13 05:48:18 EDT 2007
Hello,
inits [] = [[]]
inits (x:xs) = [[]] ++ map (x:) (inits xs)
as specified in Data.List has a "semantic bug", namely it's too strict:
inits (1:_|_) = []:_|_
as opposed to the expected
inits (1:_|_) = []:[1]:_|_
A correct version would be
inits xs = []:case xs of
[] -> []
(x:xs) -> map (x:) (inits xs)
The Haskell report specifies how inits has to behave, so this is a
problem in the report, not in a concrete implementation. Where can I
report a bug report for the report? ;)
Regards,
apfelmus
More information about the Haskell-prime
mailing list