what if i dont know the input? |
What do you mean by this?
what if its (translate (translate (rect 10 10 10 10) 50 50) 50 50)? with any number of translates? |
Technically, that doesn't change the solution.
Now, I'm assuming
(translate (rect 10 10 10 10) 50 50)
means, in English, "Make a rect at (10,10) with a width of 10 and a height of 10. Then, translate the rect by 50 in x and by 50 in y". With that assumption the parsing would go like:
1.
(translate (translate (rect
- > push "translate", push "translate", push "rect".
2.
10 10 10 10
-> compute rect with this input.
3.
)
-> pop the stack. Now, with my assumption place the computed rect onto the parameter set for the second "translate", which is now on top of the stack.
4.
50 50
-> compute translate with the computed rect and this input.
5.
)
-> pop the stack. Now, with my assumption place the translated rect onto the parameter set for the first "translate", which is now on top of the stack.
6.
50 50
-> compute translate with the translated rect and this input.
7.
)
-> pop the stack.