Grouping and Combining Elements of Lists

Functions for grouping together elements of lists.

Here is a list:

t={a,b,c,d,e,f,g}

This groups the elements of the list in pairs, throwing away the single element left at the end:

Partition[t,2]

This groups elements in triples. There is no overlap between the triples:

Partition[t,3]

This makes triples of elements, with each successive triple offset by just one element:

Partition[t,3,1]

This splits up the list into runs of identical elements:

Split[{a,a,b,b,b,a,a,a,b}]

Finding possible tuples of elements in lists.

This gives all possible ways of picking two elements out of the list:

Tuples[{a,b},2]

This gives all possible ways of picking one element from each list:

Tuples[{{a,b},{1,2,3}}]