Re: [Haskell-cafe] Haskell performance (again)!

2006-10-09 Thread Yang
On 10/8/06, Udo Stenzel u.stenzel-at-web.de |haskell-cafe| ... wrote: Yang wrote: type Poly = [(Int,Int)] addPoly1 :: Poly - Poly - Poly addPoly1 p1@(p1h@(p1c,p1d):p1t) p2@(p2h@(p2c,p2d):p2t) | p1d == p2d = (p1c + p2c, p1d) : addPoly1 p1t p2t | p1d p2d = p1h : addPoly1 p1t p2 |

Re: [Haskell-cafe] Haskell performance (again)!

2006-10-09 Thread Lennart Augustsson
I think your first try looks good. The only thing to worry about would be the + being too lazy. But that's easy to fix at the same time as improving your code in another respect. It's usually good to use real types instead of synonyms, so let's do that. data Nom = Nom Int Int type

Re: [Haskell-cafe] Haskell performance (again)!

2006-10-09 Thread Brian Hulley
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

[Haskell-cafe] Haskell performance (again)!

2006-10-08 Thread Yang
This email actually turned out much longer than I expected, but I hope it sparks interesting (and hopefully, thorough!) discussion on points that weren't touched on by previous threads on this topic. What follows describes my journey thus far exploring what I see (as a newcomer to Haskell) as a

Re: [Haskell-cafe] Haskell performance (again)!

2006-10-08 Thread ihope
On 10/8/06, Yang [EMAIL PROTECTED] wrote: And do most (experienced) Haskell users sacrifice cleanliness for speed, or speed for cleanliness? Keep the internals of your code--that which will be looked at a lot--fast and ugly, while the rest can be clean. If you have a function that does

Re: [Haskell-cafe] Haskell performance (again)!

2006-10-08 Thread ihope
On 10/8/06, ihope [EMAIL PROTECTED] wrote: Keep the internals of your code--that which will be looked at a lot--fast and ugly, while the rest can be clean. Sorry. Meant that which will be used a lot. ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Haskell performance (again)!

2006-10-08 Thread Jason Dagit
On 10/8/06, ihope [EMAIL PROTECTED] wrote: On 10/8/06, Yang [EMAIL PROTECTED] wrote: And do most (experienced) Haskell users sacrifice cleanliness for speed, or speed for cleanliness? Keep the internals of your code--that which will be looked at a lot--fast and ugly, while the rest can be

Re: [Haskell-cafe] Haskell performance (again)!

2006-10-08 Thread Duncan Coutts
On Sun, 2006-10-08 at 15:25 -0700, Jason Dagit wrote: Another good idea when you have a pretty version which is easy to verify for correctness and an ugly version that is harder to verify is to use QuickCheck or SmallCheck and define a property that says both versions are equal for all

Re: [Haskell-cafe] Haskell performance (again)!

2006-10-08 Thread Donald Bruce Stewart
duncan.coutts: On Sun, 2006-10-08 at 15:25 -0700, Jason Dagit wrote: Another good idea when you have a pretty version which is easy to verify for correctness and an ugly version that is harder to verify is to use QuickCheck or SmallCheck and define a property that says both versions are

Re: [Haskell-cafe] Haskell performance (again)!

2006-10-08 Thread Udo Stenzel
Yang wrote: type Poly = [(Int,Int)] addPoly1 :: Poly - Poly - Poly addPoly1 p1@(p1h@(p1c,p1d):p1t) p2@(p2h@(p2c,p2d):p2t) | p1d == p2d = (p1c + p2c, p1d) : addPoly1 p1t p2t | p1d p2d = p1h : addPoly1 p1t p2 | p1d p2d = p2h : addPoly1 p1 p2t addPoly1 p1 [] = p1 addPoly1 [] p2 =