for de-suguring of list comprehensions, see section 3.11 of the Haskell
Report: http://www.haskell.org/definition/
or, in this case:
area (Polygon vertices) = 0.5 * sum (concatMap ok l)
where
ok (Vertex x1 y1, Vertex x2 y2) = [(x1-x2)*(y1+y2)]
ok _ = []
l = zip vertices (tail vertices ++ [head vertices])
John
------------
Friedrich Dominicus wrote:
>
> Ronny Wichers Schreur <[EMAIL PROTECTED]> writes:
>
> > area :: Shape -> Float
> > area (Polygon vertices)
> > = 0.5 * sum [(x1-x2)*(y1+y2)
> > | (Vertex x1 y1, Vertex x2 y2)
> > <- zip vertices (tail vertices ++ [head vertices])]
> thanks, John Huges pointed me to a simular solution, JFYI list
> comprehension is not covered in that chapter nor are anonymous
> functions. I found that list comprehension is syntactic sugar for a
> map, just by sheeting (to page 90 in SOE). But I do not understand how
> to replace one by the other here. I'll have to wait and try till I
> found what list comprehansion stands for.
>
> Thanks anyway
> Friedrich
>
> --
> for e-mail reply remove all after .com
>
>