I guessed the output for
(Sequence[#, 7]&)[3]
should be
Sequence[3,7]
But my guess was wrong. See the screenshot:
And I tried to construct such function as pure-function, but failed.
A workaround (not as pure-function) is Seq[x_] := Sequence[x, 7]
Q1) Why does the code Sequence[#, 7]&)[3]
fail ?
Q2) Is it possible to construct such function as a pure-function ?
ReleaseHold@Hold[#, 7] &[3]
$\endgroup$Function
doesn't haveSequenceHold
orHoldAllComplete
attribute, If you add it manually which is not a good idea (SetAttributes[Function, SequenceHold]
) problem will be solved. $\endgroup$(Sequence @@ {#, 7} &)[3]
. $\endgroup$