Functions specialised for arrays of dimension 2.
Given the extent of an array, clamp the components of an index so they lie within the given array. Outlying indices are clamped to the index of the nearest border element.
Extent of array.
Width of border.
|-> Array r1 DIM2 a|
Array for internal elements.
|-> Array r2 DIM2 a|
Array for border elements.
|-> Array (P r1 (P r2 (P r2 (P r2 (P r2 X))))) DIM2 a|
Make a 2D partitioned array from two others, one to produce the elements in the internal region, and one to produce elements in the border region. The two arrays must have the same extent. The border must be the same width on all sides.
TODO: Check arrays have same extent.