[Haskell] why I need so much memory????

Alberto Fuentes Rodriguez fuentes008 at hotmail.com
Tue Nov 8 12:40:36 EST 2005


Hi, I am trying to make a program to generate all the poker hands.
I have done it yet and it only need a few of seconds.

Each card is represented with a Char (to make the structure smaller) and 
then all the hands are a [[Char]]
in total the structure has a size of arround 20Mb.

Now I like be sure that I have all the hands and that they are not repeated. 
To do that I have done the next function:
isRepeated :: Eq a => [a] -> Bool
isRepeated [] = False
isRepeated (p:r) = (any (\x -> x == p) r) || isRepeated r

I call it with a [[Char]] of 2598960 elements and each element with 5 
Characters.

Ok the complexity is high but.... why this program needs 1GB (the structure 
only has 20MB) of memory??
The problem is that it begins to use the swap zone and due to that It can 
only use the 10% of the processor.
I have compiled with the latest version of GHC (ghc --make -C ppal.hs).
I attach you the source files (the backtr works well) and the map memory of 
the process.

Alberto Fuentes

_________________________________________________________________
Un amor, una aventura, compañía para un viaje. Regístrate gratis en MSN Amor 
& Amistad. http://match.msn.es/match/mt.cfm?pg=channel&tcid=162349
-------------- next part --------------
A non-text attachment was scrubbed...
Name: todasManos.hs
Type: text/x-haskell
Size: 2752 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/haskell/attachments/20051108/824493f1/todasManos-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Backtr.hs
Type: text/x-haskell
Size: 3519 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/haskell/attachments/20051108/824493f1/Backtr-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Pantallazo-1.png
Type: image/png
Size: 170076 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/haskell/attachments/20051108/824493f1/Pantallazo-1-0001.png


More information about the Haskell mailing list