What is the “correct” construction in Common Lisp for applying elementary operations to multidimensional arrays?
The following examples will help illustrate what I'm trying to do:
A) Suppose I want to increase each element of an array by one:
0 1 2 1 2 3
3 4 5 -> 4 5 6
6 7 8 7 8 9
B) Suppose I want to add 2 arrays:
1 2 -1 -1 0 1
3 4 + -2 -2 -> 1 2
5 6 -3 -3 2 3
C) Suppose I want to find the largest elements from multiple arrays, elementwise:
max( 0 1 , 4 -1 , 0 0 ) -> 4 1
2 3 0 0 8 1 8 3
Basically, I think I'm looking for some kind of "arraymap" function that will be used as follows: (arraymap f A1 A2 ... An)where f takes n arguments as input and Ai accept arrays of the same size.
In the above examples, it will be used as follows:
AND)
(setq M
(arraymap
AT)
(setq M
(setq N
(arraymap
WITH)
(setq M
(setq N
(setq O
(arraymap
, , , , .