## Tuesday, August 28, 2012

### Shape dependent paralellism

Map, reverse, and transpose are paralell operations whose targeting scheme is dependent upon the shape of their argument. For example, here is the targeting scheme generated by the map operation on a list whose shape (or size) is 3 with respect to func:
{(nth 0) func
(nth 1) func
(nth 2) func}

On the other hand, reverse operation runs swap operations in parallel. With respect to a list of size five, the reverse operation runs two shape operations leaving the middle unchanged
{(list-places (nth 0) (nth 4)) swap
(list-places (nth 1) (nth 3)) swap}

Here is the transpose operation on a matrix that is shaped like [[0 1 2] [3 4 5]]:
{(list-places (nth 1) (nth 3) (nth 4) (nth 2)) (shift 4)
(list-places (compose first dimensions)
(compose second dimensions)) swap}}

The transpose operation is much more complicated then the others because it also reverses the dimensions of the grid.