# Output of List@@func

Hello I am trying to separate a function and get a list

f[x_, y_] := Sin[x]+Exp[Cos[x]]; u = List @@ f[x, y]

Output is what I want and that is

{E^Cos[x], Sin[x]}

If f[x_,y_]:= Sin[x+y] the output is {x + y}. I wanted output to be {Sin[x+y]}. Is there a way to do this?

Thank you

Erdem

• Evaluate List @@ f //Trace to see what is happening. Also note f is not defining a function in either of the examples in your post. – Edmund Nov 12 '17 at 17:26
• Thanks, the solution is there. I just need to find the way to extract it. – Erdem Nov 12 '17 at 17:55
• You need to say more about the scope of the solution you are looking for. The @@ notation (for Apply) replaces the head of the expression. In the first example, you replace a head of Plus, and apparently you want to replace the head. In the second, you replace a head of Sin, but apparently you do not want to replace the head. So, what is your actual goal, generally stated? – Alan Nov 12 '17 at 18:17
• I want to able to separate the function for summations and subtractions. Like Sin[x+y]-1+ Sin[x] Exp[Cos[z]] to {Sin[x+y],-1,Sin[x] Exp[Cos[z]]} – Erdem Nov 12 '17 at 18:26
• As @Alan explained, List@@ replaces the head of the expression by List, which is fine if the head is, for instance Plus. In the second example, the head is Sin, so use {f[x, y]} instead to obtain {Sin[x+y]}. Use FullForm to see the internal structure of an expression, but be prepared for a lot of output. – bbgodfrey Nov 12 '17 at 18:36

terms[expr_] := If[Head@expr === Plus, Level[expr, 1], {expr}]