[Haskell-cafe] Space Leak Help
Dominic Steinitz
dominic.steinitz at blueyonder.co.uk
Sun Feb 4 03:20:23 EST 2007
On Saturday 03 February 2007 19:56, Pepe Iborra wrote:
> pad :: [Word8] -> [Word8]
> pad xs = pad' xs 0
>
> pad' (x:xs) l = x : pad' xs (succ l)
> pad' [] l = [0x80] ++ ps ++ lb
> where
> pl = (64-(l+9)) `mod` 64
> ps = replicate pl 0x00
> lb = i2osp 8 (8*l)
Pepe,
Thanks but this gives me a different problem
dom at heisenberg:~/sha1> ./allInOne 1000001 +RTS -hc -RTS
[2845392438,1191608682,3124634993,2018558572,2630932637]
[2224569924,473682542,3131984545,4182845925,3846598897]
Stack space overflow: current size 8388608 bytes.
Use `+RTS -Ksize' to increase it.
Someone suggested
pad :: Num a => [a] -> [a]
pad = pad' 0
where pad' !l [] = [0x80] ++ ps ++ lb
where pl = (64-(l+9)) `mod` 64
ps = replicate pl 0x00
lb = i2osp 8 (8*l)
pad' !l (x:xs) = x : pad' (l+1) xs
but that didn't compile
*Main> :r
[2 of 2] Compiling Main ( allInOne.hs, interpreted )
allInOne.hs:83:14: Parse error in pattern
Failed, modules loaded: Codec.Utils.
Dominic.
More information about the Haskell-Cafe
mailing list