Changed "tuple" to "i" in type signatures, to make things match.
Changed definition of duplicate so that it's easier to see the pattern in how it works in different dimensionalities.