Functorized Undo/Redo .The idea to marry the algorithm with the functor was encouraging and this is example code for it