Jump to content

Shoelace formula for polygonal area: Difference between revisions

Added 11l
(Added 11l)
Line 14:
Show the answer here, on this page.
<br><br>
 
=={{header|11l}}==
{{trans|Python}}
 
<lang 11l>F area_by_shoelace(x, y)
R abs(sum(zip(x, y[1..] [+] y[0.<1]).map((i, j) -> i * j))
-sum(zip(x[1..] [+] x[0.<1], y).map((i, j) -> i * j))) / 2
 
V points = [(3, 4), (5, 11), (12, 8), (9, 5), (5, 6)]
V x = points.map(p -> p[0])
V y = points.map(p -> p[1])
 
print(area_by_shoelace(x, y))</lang>
 
{{out}}
<pre>
30
</pre>
 
=={{header|360 Assembly}}==
1,480

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.