Haskell - Lempel-Ziv 78 Compression - very slow, why? -
so i've finished lempel-ziv compression/decompression, compared c++ unbelievably slow, i've tried on http://norvig.com/big.txt file, program can't process it, while in c++ took 1 second. of haskell gurus @ code , tell me if there obvious flaws? after adding prepending instead of appending, managed reduce time 16 seconds 0.4! haskell's laziness deceiving, printing 'compression finished' immediately, in fact compression made program run slow import system.io import control.monad import qualified data.map map import debug.trace main = contents <- readfile "plik.txt" let compressed = reverse $ compress contents map.empty 1 "" [] let decompressed = reverse $ decompress compressed map.empty 1 "" --print $ contents print $ length compressed print $ length decompressed --print $ contents == decompressed compress :: string -> map.map string int -> int -> string -> [(int,char)]-> [(int,char)...