Shoelace formula for polygonal area: Difference between revisions
m
→{{header|Python}}: (Tidying)
m (→{{header|Haskell}}: Some tidying and reduction.) |
m (→{{header|Python}}: (Tidying)) |
||
Line 1,066:
<lang python>'''Polygonal area by shoelace formula'''
from itertools import
from functools import
from operator import sub
Line 1,078 ⟶ 1,079:
l, r = a
(x, y), (dx, dy) = tpl
return
return abs(
go,
zip(
islice(cycle(xys), 1)
(0, 0)
))) / 2
Line 1,096 ⟶ 1,099:
print(__doc__ + ':')
print(repr(ps) + ' -> ' + str(shoelaceArea(ps)))
▲ return xs[1:]
▲ return xs
|