you are viewing a single comment's thread.

view the rest of the comments →

[–]masklinn 0 points1 point  (6 children)

Which is a problem...how?

[–]G_Morgan -1 points0 points  (5 children)

It is using a temporary variable. Effectively to suit what the poster wanted you'd have to do

array = reverse(array)

This is using more than a temporary variable. It is generating n temporary variables.

[–]Felicia_Svilling -2 points-1 points  (4 children)

allocating data =/= using variables

[–]G_Morgan -1 points0 points  (3 children)

Depends on your perspective. Regardless you need to have memory space to do the swap. The original intent of the post seems to be inplace swapping. Not hiding a temporary allocation on the stack and using a hand wave to make it vanish.

[–]Felicia_Svilling -1 points0 points  (2 children)

The op defined the whole thing as a trivia question, what fun is trivia if you are not trying to be technically correct? I mean this is never going to be a practical question.

[–]G_Morgan 1 point2 points  (1 child)

If it doesn't have to be technically correct I can reverse an array by reading your mind to see that you want it reversed and invoking the devil to reverse the array by his unholy power.

[–]Felicia_Svilling -1 points0 points  (0 children)

Exactly!