Simulate useState across renders. Input: line 1 — initial value (number); following lines: set N (replace) or fn +N/fn -N (functional update). Print the state after EACH update, one per line.
Input: initial then updates. Output: state after each update.
Your program reads from stdin and prints to stdout.
Example 1
Input: 0 set 5 fn +3 fn -2
Output: 5 8 6
Hints
Simulate useState across renders. Input: line 1 — initial value (number); following lines: set N (replace) or fn +N/fn -N (functional update). Print the state after EACH update, one per line.
Input: initial then updates. Output: state after each update.
Your program reads from stdin and prints to stdout.
Example 1
Input: 0 set 5 fn +3 fn -2
Output: 5 8 6
Hints