Problems

Updater Function Order

MediumProps & State

Counter state starts at an integer. Each following line is either a number (set to that value) or inc N (functional updater: previous + N). Updaters see the LATEST value. Print the final count.

Input: initial value, then operations. Output: final count.

Your program reads from stdin and prints to stdout.

Example 1

Input: 0 inc 1 inc 1 inc 1

Output: 3

Hints

ReactStateUpdaters
Updater Function Order | CodeForge AI