Merged alternative implementation for "reverse" (datastructures, exercise 18)