
Daniel McAllansmith
On Friday 25 May 2007 06:50, Grzegorz wrote:
Hi all, I have a simple piece of code which is giving me stack overflow. I guess I need to make it stricter sowhere but I can't figure out extactly where. So I thought I'd ask the experts.
I'm not sure. A real expert from the list will probably tell you what the cause of the overflow is.
As for finding the mean hamming distance, have you considered something like the following:
hammingDistance xs ys = length (filter not (zipWith (==) xs ys))
meanHammingDistance xss yss = sumHDs / cntHDs where hds = map (uncurry hammingDistance) [(xs, ys) | xs <- xss, ys <- yss] sumHDs = fromIntegral (sum hds) cntHDs = fromIntegral (length hds)
Originally I had something like that but it was very slow (approx 40 times slower than calling out to C). Someone on #haskell advised me to manually deforest the lists: the code I posted was my attempt at that. Thanks, -- Grzegorz