0
$\begingroup$

Say I have a list:

  list= {(Row[{Subscript[x, 2]}] \[CirclePlus] 
 1)/Subscript[x, 1], (Row[{Subscript[x, 
 1], Subscript[x, 3]}] \[CirclePlus] 
 1)/Subscript[x, 2], 
 (Row[{Subscript[x, 2]}] \[CirclePlus] 
 1)/Subscript[x, 3], (Row[{Subscript[y, 
 2]}] \[CirclePlus] 1)/Subscript[x, 1], 
 (Subscript[x, 1] \[CirclePlus] 
 Subscript[y, 3])/Subscript[x, 2], 
 (Subscript[y, 3] \[CirclePlus] 
 (Subscript[y, 2] + Subscript[y, 
 3]))/Subscript[x, 1]}

Now, if possible, I'd like to sequentially update that list, where

Subscript[y,1] = list[[1]]
Subscript[y,2] = list[[2]]
Subscript[y,3] = list[[3]]
Plus[Subscript[y,1],Subscript[y,2]] = list[[4]]
Plus[Subscript[y,2],Subscript[y,3]] = list[[5]]

So say as we go through list first three elements would remain unchanged where in the forth element we would replace Subscript[y,2] with list[[2]], Subscript[y,3] with list[[3]] in the fifth element, Subscript[y,3] with list[[3]] and Plus[Subscript[y,2],Subscript[y,3]] with already updated list[[5]] in the sixth element.

I have been trying to avoid word Replace wherever I could and this was for a reason. One could solve my problem, for this list, quite easily using Replace ( or ReplaceAll )but as this list becomes larger and much more complicated where elements are more nested and nested, Replace doesn't work very well. Thus, since I know that every consecutive element in my list is expressed in terms of the (updated) elements of that list sitting before that element, I thought I could somehow update element by element as I 'loop' through the list. I'd greatly appreciate some suggestions.

PS. How can I paste the output expressions here as they appear in the notebook and not just as a bunch of code?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.