# How to “explode” a list inside a function call argument list? [duplicate]

I'm trying to do something like below, but it doesn't work, since StringForm requires each item from parts to be given individually, and not in a list:

parts = ToString /@ {1, 2, 3};
(* this should be StringForm["  ", 1, 2, 3] and
not StringForm["  ", {1, 2, 3}] *)
StringForm["  ", parts]


I think this could be done with Flatten and Apply, but can I avoid using Apply? (looks ugly)

-

## marked as duplicate by Kuba, Sjoerd C. de Vries, Artes, Simon Woods, m_goldbergOct 14 '13 at 12:22

How about: parts = Sequence @@ ToString /@ {1, 2, 3} –  RunnyKine Oct 14 '13 at 2:49
@RunnyKine Yep, that was exactly what I was looking for. I read about Sequence and tried using it, but I missed the @@ part –  Adal Oct 14 '13 at 3:15
@RunnyKine I notice you used @@ which is shorthand for Apply, which the OP wanted to avoid. –  Sjoerd C. de Vries Oct 14 '13 at 7:17
@SjoerdC.deVries I think OP meant Apply[f, expr] form. –  Kuba Oct 14 '13 at 7:25
@kuba In that case, StringForm["  ", ##]& @@ parts would be better IMHO. No need for Sequence. -- Oh, forget it, I just saw you already did that. –  Sjoerd C. de Vries Oct 14 '13 at 11:44

 parts = Sequence @@ ToString /@ {1, 2, 3}

-

For StringForm you don't have to use ToString on arguments.

One way to avoid Apply, which was introduced to me by rm-rf, was to use Operate:

parts = {1, 2, 3};
StringForm["  ", Operate[Sequence &, parts]]

1 2 3


Also, if you want to use Apply in slightly different way than RunnyKine:

parts = {1, 2, 3};

StringForm["  ", ##] & @@ parts

1 2 3

-