Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Split a list into two sublists, gathering every other element of the list
ResourceFunction["EveryOther"][{e1,e2,e3,e4,…}] returns {{e1,e3,…},{e2,e4,…}}. | |
ResourceFunction["EveryOther"][{e1,e2,…},n] returns n sublists {{e1,e1+n,…},…{en,e2n,…}}. |
Split the List, combining elements in odd and even positions:
In[1]:= |
Out[1]= |
Group elements separated by gaps of length n:
In[2]:= |
Out[2]= |
Transpose[Partition[list,2]] gives the same result as EveryOther[list], as long as list has an even number of elements:
In[3]:= |
Out[3]= |
In[4]:= |
Out[4]= |
In[5]:= |
Out[5]= |
Transpose[Partition[list,n]] gives the same result as EveryOther[list,n], as long n evenly divides Length[list]:
In[6]:= |
Out[6]= |
In[7]:= |
Out[7]= |
In[8]:= |
Out[8]= |
This work is licensed under a Creative Commons Attribution 4.0 International License