Previous: map-grid, Up: Mapping


4.3.5.3 map-n-grids
— Function: grid:map-n-grids &key sources destination destination-affi destination-specification initial-element element-functions combination-function combine-destination

Map on multiple source grids. The arguments are: sources: A list of (grid-or-function affi), each one representing either a grid or function from which data will be drawn. If it is a grid, the grid values are used. If it is a function of the appropriate number of non-negative integer arguments, values will be created by calling that function on the indices. If affi is not specified and grid-or-function is a grid, the affi will default to the affi of that grid.

destination:
A grid in which to put the results, or nil if one is to be created.
destination-affi:
An affi for the destinattion.
destination-specification:
A specification for the destination, if destination-affi is not given.
initial-element: Initial value to give to the destination grid.
element-functions:
A list of functions or nil, one for each source. This function is applied to the source element before combination.
combination-function:
A function that combines each of the source values after being passed through the element-functions. If nil, then just take the value from the first source.
combine-destination:
If true, pass as the first argument to the combination-function the prior value of the destination grid. Defaults to t if :desination is specified; otherwise nil.
This is a more general form of map-grid which can take multiple source grids, instead of only one. For example, combine arrays a and b as a+2b:
     (map-n-grids :sources `((,#31m(1 2 3) nil) (,#31m(9 8 7) nil))
                  :combination-function (lambda (a b) (+ a (* 2 b))))