BlockMap

BlockMap[f,list,n]

applies f to non-overlapping sublists of length n in list.

BlockMap[f,list,n,d]

applies f to sublists with offset d in list.

BlockMap[f,list,{n1,n2,},]

applies f to blocks of size n1×n2×.

Details

Examples

open allclose all

Basic Examples  (4)

Apply a function to all non-overlapping, length-2 sublists:

In[1]:=
Click for copyable input
Out[1]=

Apply a function to overlapping sublists of length 2 with offset 1:

In[1]:=
Click for copyable input
Out[1]=

Apply a function to a matrix:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=

Apply a function to all 2x2 sub-matrices:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]//MatrixForm=

Scope  (7)

Applications  (5)

Properties & Relations  (2)

See Also

ArrayFilter  Partition  Map  MapIndexed  ListCorrelate  MovingMap  CellularAutomaton

Introduced in 2015
(10.2)