• incanter

1.2.3-SNAPSHOT

# matrix-map

## incanter.core

• (matrix-map f m)
• (matrix-map f m & ms)
Like clojure.core/map, but will work on matrices of any dimension:
1 x 1 (like e.g. a Double), 1 x n, n x 1, and n x m

Examples:
(use '(incanter core))
(def mat (matrix (range 9) 3))
(matrix-map #(mod % 2) mat)
(matrix-map #(mod % 2) (first mat))
(matrix-map #(mod % 2) (\$ 1 0 mat))
(matrix-map #(mod % 2) [1 2 3 4])
(matrix-map #(mod % 2) 9)

### Source incanter/core.clj:1834 top

```(defn matrix-map
"Like clojure.core/map, but will work on matrices of any dimension:
1 x 1 (like e.g. a Double), 1 x n, n x 1, and n x m

Examples:
(use '(incanter core))
(def mat (matrix (range 9) 3))
(matrix-map #(mod % 2) mat)
(matrix-map #(mod % 2) (first mat))
(matrix-map #(mod % 2) (\$ 1 0 mat))
(matrix-map #(mod % 2) [1 2 3 4])
(matrix-map #(mod % 2) 9)

"
([f m]
(if (sequential? m)
(if (sequential? (first m))
(map (fn [& a] (apply map f a)) m)
(map f m))
(f m)))
([f m & ms]
(if (sequential? m)
(if (sequential? (first m))
(apply map (fn [& a] (apply map f a)) m ms)
(apply map f m ms))
(apply f m ms))))```
Vars in incanter.core/matrix-map: apply defn first fn map sequential?
Used in 0 other vars