### Computing two dimensional functions

Posted:

**Thu May 14, 2009 10:36 pm**How one can write a function "map2D" that will be a 2-dimensional equivalent of the standard "map" function?

In other words, I like it to work like in the following example:

Line:

should return a result:

because:

1 + 2 = 3, or equivalently:

3 + 4 = 7, or equivalently:

5 + 6 = 11, or equivalently:

Here "+" is acting like a function of two variables that is acting of every pair from the given list.

In other words, I like it to work like in the following example:

Line:

- Code: Select all
`(map2D + '((1 . 2) (3 . 4) (5 . 6)) )`

should return a result:

- Code: Select all
`(3 7 11)`

because:

1 + 2 = 3, or equivalently:

- Code: Select all
`(+ 1 2) == 3`

3 + 4 = 7, or equivalently:

- Code: Select all
`(+ 3 4) == 7`

5 + 6 = 11, or equivalently:

- Code: Select all
`(+ 5 6) == 11`

Here "+" is acting like a function of two variables that is acting of every pair from the given list.