[Haskell-beginners] Critique my Code!

Christian Maeder Christian.Maeder at dfki.de
Fri Apr 1 09:52:16 CEST 2011

Am 31.03.2011 17:55, schrieb blackcat at pro-ns.net:
> Hi,
> I was hoping to get a code critique from some experienced Haskell
> people. I put my code up in this blog post:
> http://learnmeahaskell.blogspot.com/2011/03/playing-around-with-quickcheck.html
> .

Without trying to understand your code I'm disturbed by

a) duplicate code in factors' namely
      x `mod` y == 0 && y*y ...
      factors' x (y+1)

b) "sort $ nub" (even twice)

first sort and then removing duplicates can be more efficient, I would 
suggest: "Data.Set.toList . Data.Set.fromList"

c) using (head xs) and (tail xs) in "check" (without "null xs" test) 
looks suspicious. Use pattern matching on xs (instead of on number y)!

HTH Christian

> thanks
> Lee

More information about the Beginners mailing list