
Thanks.
Pattern matching and memory management in Haskell (or may be GHC
implementation of it) is somewhat of a mystery to me. Are there any
references that explains the underlying implementation?
Daryoush
On Mon, Sep 8, 2008 at 6:37 PM, Mauricio
abs (Pt {pointx = x, pointy = y}) = sqrt (x*x + y+y)
Why is it pointx=x and not x=pointx?
Your intuition is probably telling you that this is something like:
abs (point) = sqrt (x*x+y*y) where {x=pointx point ; y=pointy point}
Actually, it's an example of pattern matching:
abs (Pt {pointx=3 , pointy=4}) = 5 abs (Pt {pointx=3 , pointy=y}) = sqrt (9+y*y) abs (Pt {pointx=z , pointy=z}) = (sqrt 2)*z
etc.
Best, Maurício
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Daryoush Weblog: http://perlustration.blogspot.com/