I defined a function f
like
f[x___, y_] := something;
and if x
s and y
are all number, when I use this function, I would input like this:
f[1, 5, 3, 6, 3]
For this, x = Sequence[1, 5, 3, 6]
and y = 3
.
Suppose that I have a list l = {1, 5, 3, 6}
.
Then I might use f
like
f[l /. List -> Sequence, 3]
using ReplaceAll
to convert List
to Sequence
.
It is very good way to convert I think.
But, the problem is, when I want to input
f[1, {5, 3}, 6, 3]
which is given by l = {1, {5, 3}, 6}
, if I use /.
, ReplaceAll
, {5, 3}
is also converted into the sequence so the whole input becomes f[1, 5, 3, 6, 3]
, not f[1, {5, 3}, 6, 3]
.
I have searched several alternative functions like Replace
which includes a levelspec
option. But Replace
can not convert List
.
How can I convert without loss of inside lists?