apply#
Reduce slices of a matrix using a callback.
Available in: math cells, REPL.
Syntax#
apply(A, dimension, callback)
Arguments and behavior#
Dimension is one-based in a cell. Use a function name as callback. mapSlices is the clearer modern spelling.
Example#
Edit the inputs, then use Run or Reset. Changes stay in this example.
Example
apply([[1,2],[3,4]],1,sum)Interactive examples could not load. You can still copy the expressions.
Expected result: matrix.