
9 May
2008
9 May
'08
2:20 p.m.
Hi
data List a = Zero | One a | Two (List a) (List a)
On Fri, May 9, 2008 at 3:16 PM, Andrew Coppin
The function (++) :: [x] -> [x] -> [x] has O(n) complexity.
(++) = Two -- O(1) complexity
If somebody were to invent some type that looks like [x] but actually uses some sort of tree rather than a linked list, you should be able to get O(1) concatenation. Has anybody ever implemented such a thing?
Yes. Me, last month. http://www.cs.york.ac.uk/fp/darcs/uniplate/Data/Generics/Str.hs I wasn't the first though - it's been in Lava for years as well, which is where I got my inspiration. Thanks Neil