reduce

Returns the next state for action without mutating state.