The head Sequence is rarely seen in directly.  Consider the function (f)
below, where the first two arguments are p1,and p2, and all the remaining
arguments are part of p3.  All the remaining arguments go with p3 because the
definition of (f) uses BlankSequence (___) for p3.  The only thing the
function (f) does is return p3.  One might wonder what head is given to p3.  
It turns out it is given the head Sequence. After (f) is defined, we use it
to make the Sequence (seq).

ClearAll[f, foo, h] ;  f[p1_, p2_, p3__] := p3 ;  seq = f[9, 10, 11, 12, 13, 14, 15]

Sequence[11, 12, 13, 14, 15]

If you have a number of sequences inside almost any head the sequences are  automatically flattened, and the fact that the arguments are a sequence is  not indicated (see the example in the next line).  The only functions that  don't splice the sequences together are those with the Attribute SequenceHold.

{Sequence[2, 3, 4, Sequence[7, 8]]}

{2, 3, 4, 7, 8}

Most useful applications of Sequence are variations of the next cell where
the head (h) is changed to Sequence and the effect is that h[7,11,13] is
changed to (7,11,13).

foo[2, 3, 5, h[7, 11, 13], 17]/.hSequence

foo[2, 3, 5, 7, 11, 13, 17]

Created by Mathematica  (May 16, 2004)

Back to Ted’s Tricks index page