[Haskell-cafe] Re: Pickling a finite map (Binary + zlib) [was:
Data.Binary poor read performance]
Christian.Maeder at dfki.de
Tue Feb 24 13:46:28 EST 2009
>> fromDistinctAscList :: [(k,a)] -> Map k a
>> fromDistinctAscList xs
>> = build const (length xs) xs
>> -- 1) use continutations so that we use heap space instead of stack space.
>> -- 2) special case for n==5 to build bushier trees.
>> build c 0 xs' = c Tip xs'
>> build c 5 xs' = case xs' of
>> -> c (bin k4 x4 (bin k2 x2 (singleton k1
>> x1) (singleton k3 x3)) (singleton k5 x5)) xx
By the way, did anyone test if (or when) this n==5 case "bushier trees"
More information about the Haskell-Cafe