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

Riffle

Riffle
gives .
Riffle
gives .
Riffle
yields a list in which every n^(th) element is x.
Riffle
yields a list in which x appears if possible at positions , , , ... , .
  • If there are fewer than gaps between in Riffle, the are used cyclically.
  • The specification is of the type used in Take. Negative indices count from the end of the list.
  • In Riffle, if list and xlist are of the same length, then their elements are directly interleaved, so that the last element of the result is the last element of xlist.
Riffle between successive elements in a list:
Riffle in and cyclically:
Riffle in at every 3^(rd) position:
Riffle between successive elements in a list:
In[1]:=
Click for copyable input
Out[1]=
 
Riffle in and cyclically:
In[1]:=
Click for copyable input
Out[1]=
 
Riffle in at every 3^(rd) position:
In[1]:=
Click for copyable input
Out[1]=
Riffle in at every other position:
Include at the beginning and end:
Use step 3:
Start riffling in only at position 5:
Cyclically riffle in and :
Intersperse two lists:
Riffle works on SparseArray objects:
Insert spaces between words:
Create a directory name from a path list:
Insert 0s between successive integers:
Alternate positive and negative integers:
Insert commas at every 4^(th) character:
New in 6