examples/calculator: implement state saving and loading