# Von Neumann Neighborhood

## APL (Dyalog Extended), 23 bytes

-4 thanks to ovs.

Anonymous tacit infix function, taking coordinates of a cell and radius as left and right arguments. Requires 0-based indexing.

```
{⍺∘+¨⍵-⍸⍵≥+/¨|∘.,⍨⍵…-⍵}
```

Try it online!

`{`

…`}`

"dfn"; left argument is `⍺`

and right argument is `⍵`

:

`⍵…-⍵`

inclusive integer range from radius to negative radius

`∘.,⍨`

Cartesian selfie product

`⊢m←`

assign to `m`

and pass that

`|`

absolute values

`+/¨`

sum each (gives matrix of Manhattan distances)

`⍵≥`

indicate which ones are less than or equal to the radius

`⍸`

**ɩ**ndices where true

`⍵-`

subtract from radius

`⍺∘+¨`

add the cell coordinates to each

## 05AB1E, ~~14~~ 13 bytes

-1 thanks to ovs

```
D(ŸãʒÄO¹[email protected]}€+
```

Try it online!

Takes input as range, coordinates

Explanation:

```
D duplicate the range in the stack
( negate
Ÿ push the range [-range..range]
ã Cartesian power
ʒ filter
Ä absolute value, vectorizes over each of the coordinates
O sum - distance from 0,0
¹[email protected] less than or equals to the range
} end filter
€ map
+ add, with the implicit center coordinate
```

## Perl 5, 64 bytes

```
sub n($x,$y,$d){map{//;map[$x+$',$y+$_],-$d+abs..$d-abs}-$d..$d}
```

Try it online!

Saved 4 bytes, thanks to Xcali.