This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Riffle

Riffle[{e1, e2, ...}, x]
gives {e1, x, e2, x, ...}.
Riffle[{e1, e2, ...}, {x1, x2, ...}]
gives {e1, x1, e2, x2, ...}.
Riffle[list, x, n]
yields a list in which every n^(th) element is x.
Riffle[list, x, {imin, imax, n}]
yields a list in which x appears if possible at positions imin, imin+n, imin+2n, ... , imax.
  • If there are fewer xi than gaps between ei in Riffle[{e1, e2, ...}, {x1, x2, ...}], the xi are used cyclically.
  • The specification {imin, imax, n} is of the type used in Take. Negative indices count from the end of the list.
  • Riffle[list, x] is equivalent to Riffle[list, x, {2, -2, 2}].
  • Riffle[list, x, n] is equivalent to Riffle[list, x, {n, -1, n}].
"Riffle" x between successive elements in a list:
In[1]:=
Click for copyable input
Out[1]=
 
Riffle in x and y cyclically:
In[1]:=
Click for copyable input
Out[1]=
 
Riffle in x at every third position:
In[1]:=
Click for copyable input
Out[1]=
New in 6