> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/s/shoelace_formula_for_polygonal_area.md).

# Shoelace formula for polygonal area

```ruby
func area_by_shoelace (*p) {
    var x = p.map{_[0]}
    var y = p.map{_[1]}

    var s = (
        (x ~Z* y.rotate(+1)).sum -
        (x ~Z* y.rotate(-1)).sum
    )

    s.abs / 2
}

say area_by_shoelace([3,4], [5,11], [12,8], [9,5], [5,6])
```

## Output:

```
30
```
