Alberto Fuentes Rodriguez wrote:
isRepeated :: Eq a => [a] -> Bool isRepeated [] = False isRepeated (p:r) = (any (\x -> x == p) r) || isRepeated r
Two comments: You can write "any (==p) r", using a partial application of the equality predicate. Reads better IMHO. This is O(n²), sorting and checking should be O(n log n). You might be better off generating only unque hands from the start? If you can generate a lazy stream of hands, and the stream can be consumed lazily, it will save a lot or memory. (Three comments, I mean)
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.
You can try to limit the heap -- for me, about 80% of physical RAM seems to be a good choice. (E.g. +RTS -M800M) -k