In[1] := {a, b, Sequence @@ {}, c}
Out[1] := {a, b, c}
In[2] := {a, b, Sequence[], c}
Out[2] := {a, b, c}
In[3] := {a, b, If[1 == 0, x, Sequence @@ {}], c}
Out[3] := {a, b, c}
In[4] := {a, b, If[1 == 0, x, Sequence[]], c}
Out[4] := {a, b, Null, c}
How do you explain this peculiar sequence of commands? In the last example, my guess is that the sequence is evaluated on the if statement itself, shrinking it to If[1 == 0, x] so that the false evaluation gives Null instead. Doesn't If have a HoldForm or something on the arguments to ensure that this doesn't happen? And why does example 3 work in that case? My application is a long list of the form {a,b,x,c} or {a,b,c} and I want to make the x appear in the list under a condition, without writing a,b,c twice (it would be equivalent to If[cond,{a,b,x,c},{a,b,c}]).
{a, b, If[1 == 0, x, Evaluate[Sequence @@ {}]], c}returns{a, b, Null, c}. I think it is caused by the order of evaluation. – vapor Apr 19 '15 at 12:34SequenceHoldas the explanation for "shrinking" toIf[1 == 0, x]. – Mr.Wizard Apr 19 '15 at 16:55Unevaluated[]and##&[]that you mention in the other answer either. – Mario Carneiro Apr 20 '15 at 05:10