# mapSlices() Function & Examples

Use the mapSlices() matrix function in Calcul.io. Review its syntax, edit working examples, understand the result, and explore related math functions.

## mapSlices

#### mapSlices(A, dim, callback)

Try it yourself:

```calculio
A = [[1, 2], [3, 4]]
mapSlices(A, 1, sum)
mapSlices(A, 2, prod)
```

[map](https://calcul.io/function/map/index.md)

---

## mapSlices(): Transforming Matrix Slices

**mapSlices()** applies a function to slices of a matrix along selected dimensions. It is useful when work should happen row by row, column by column, or across higher-dimensional blocks rather than entry by entry.

## Choose dimensions carefully

Know which axis represents observations and which represents features before mapping slices. Check shape with [size()](https://calcul.io/function/size/index.md), and compare with [map()](https://calcul.io/function/map/index.md), which processes individual entries. For row or column extraction, use [row()](https://calcul.io/function/row/index.md) and [column()](https://calcul.io/function/column/index.md).

Slice functions should return compatible outputs if they will be assembled into a matrix. Use [mean()](https://calcul.io/function/mean/index.md) for per-slice summaries or [sum()](https://calcul.io/function/sum/index.md) for aggregation.

[All functions](https://calcul.io/functions/index.md)
