R solution using self-modifying code

This solution uses a function that modifies its arguments. It also uses a feature of R's promise evaluation -- that it can return a value immediately.