"Brian Hulley" <[EMAIL PROTECTED]> writes: > Lennart Augustsson wrote: > > I think your first try looks good. > [snip] > > ... > > addPoly1 p1@(p1h@(Nom p1c p1d):p1t) p2@(p2h@(Nom p2c p2d):p2t) > > | p1d == p2d = Nom (p1c + p2c) p1d : addPoly1 p1t p2t > > | p1d < p2d = p1h : addPoly1 p1t p2 > > | p1d > p2d = p2h : addPoly1 p1 p2t > > ... > > The last comparison is redundant (this was in the original > version too) because p1d > p2d is implied (certainly for > this case where p1d, p2d::Int) by the fall through from not > satisfying == and < so how about: > > addPoly1 p1@(p1h@(Nom p1c p1d):p1t) p2@(p2h@(Nom p2c p2d):p2t) > | p1d == p2d = Nom (p1c + p2c) p1d : addPoly1 p1t p2t > | p1d < p2d = p1h : addPoly1 p1t p2 > | otherwise = p2h : addPoly1 p1 p2t
Surely all but one of the comparisons is unnecessary? If you use `compare` instead of (==) and friends, won't one do (I'm assuming that the compiler can convert cases on LT, EQ and GT into something sensible -- after all, wasn't that the purpose of compare?)? -- Jón Fairbairn [EMAIL PROTECTED] http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html (updated 2006-09-13) _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe