Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

(bbfu) (array vs. list reversal) Re4: (OT) Interview questions -- your response?

by bbfu (Curate)
on Sep 05, 2002 at 05:13 UTC ( #195293=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Re: (OT) Interview questions -- your response?
in thread (OT) Interview questions -- your response?

So we are not reversing the array...

...just reversing the list. List, array; array, list. While they are technically different (one is a Perl data structure, while the other is an anonymous collection of scalar values), I don't see how that difference really matters in this case. =) You're still using Perl's built-in to reverse a list/array, whether it's the original array, or the list of array indices. It's just semantics.

I mean, by those standards, reverse technically accepts a LIST, not an ARRAY (and will flatten multiple arrays into a single list, for example), so you should be able to do: @array = reverse @array;, since reverse isn't actually reversing the array but, rather, the list passed to it (after which, the reversed list is passed back and stored into the original array, replacing the original contents). Of course, as Aristotle points out, both of these methods (using Perl's built-in reverse, and your method of reversing the list of indices) fail the "in-place" clause of the original problem, so it's all moot. =)

Black flowers blossum
Fearless on my breath
Teardrops on the fire
Fearless on my breath

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://195293]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2019-05-27 06:15 GMT
Find Nodes?
    Voting Booth?
    Do you enjoy 3D movies?

    Results (154 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!