So in my notebook I have a list of long expressions which are sums of a bunch of terms. I would like to look at each of these terms individually and try to remove them based on some criteria. My idea was to replace the head of the first Plus with List, and then look at the individual terms from there as they would be separated into a list. I want to use Replace instead of ReplaceAll because on lower levels there may be sums inside exponentials that I don't want to replace. A toy illustration of what I'm doing now (which doesn't work) is something like this:
Replace[{x+y},Plus -> List, 1]
In my mind this should work, but it doesn't seem to. ReplaceAll works ok
ReplaceAll[{x+y},Plus -> List]
but I don't think this is really what I want. Any help would be greatly appreciated, or even a different way of approaching the problem would be great too!
Replace
worked that way, the third argument should have been{2}
.Plus
is at level 2 because you need two numbers to obtain it with part{x+y}[[1,0]]
$\endgroup$MapAt[List&, expr, Position[expr, Plus, {2}]]
$\endgroup$Apply
with a level specification may be what you need :Apply[List,{x+y},{1}]
$\endgroup$