How to iterate recursively through a list in subtraction with another list.

jospercomp shared this question 1 year ago
Answered

vi=30

ls={1,5,-4}

/////////////////////////


30-1=29

29-5=24

24-(4)=28

output1: [29,24,28]

output2: [30,-1,29,-5,24,4,28]

Best Answer
photo

Recursive?

Try

Sequence(30-Sum(Take(ls,1,j)),j,1,3)

Join({30},Flatten(Sequence({-ls(j),30-Sum(Take(ls,1,j))},j,1,3)))

Comments (1)

photo
2

Recursive?

Try

Sequence(30-Sum(Take(ls,1,j)),j,1,3)

Join({30},Flatten(Sequence({-ls(j),30-Sum(Take(ls,1,j))},j,1,3)))

© 2022 International GeoGebra Institute