Shoelace formula for polygonal area: Difference between revisions

m
→‎{{header|Perl 6}}: minor simplification
(→‎{{header|Perl 6}}: Add a Perl 6 example)
m (→‎{{header|Perl 6}}: minor simplification)
Line 47:
 
<lang perl6>sub area-by-shoelace(@p) {
(^@p.end).map({@p[$_;0] * @p[($_+1)%@p;1] - @p[$_;1] * @p[($_+1)%@p;0]}).sum.abs / 2
@p.push: @p[0];
(^@p.end).map({@p[$_;0] * @p[$_+1;1] - @p[$_;1] * @p[$_+1;0]}).sum.abs / 2
}
 
10,333

edits