Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: For vs. While

by Andrew_Levenson (Hermit)
on Dec 06, 2006 at 00:54 UTC ( #588010=note: print w/replies, xml ) Need Help??


in reply to Re: For vs. While
in thread For vs. While

Ahh, that makes perfect sense. Thanks!
V(qw/74 401 211 79/);sub V{while(@_){$v**=$V?$#_:$V; print(map{$V<$v?chr(shift):chr(reverse(pop))}$_),$V+=$#_%2!=1?1:0}}

Replies are listed 'Best First'.
Re^3: For vs. While
by ikegami (Pope) on Dec 06, 2006 at 01:10 UTC

    That behaviour is specifically for for (@array). for (@array) is different than other forms of for (LIST). As soon as one iterates over anything but just an array, it's the size of the list on the stack that matters.

    The real difference is that for (@array) is optimized to avoid flattening @array onto the stack. Instead, for (@array) navigates @array in place. For all other expressions, a list is formed on the stack and for iterates over that.

    The following show the difference between iterating in place, and iterating over a list on the stack.

    sub f4 { for (@_) { print($_); shift; } print("\n"); } sub f5 { for ((), @_) { print($_); shift; } print("\n"); } f4(map/./g, Japh); # Jp f5(map/./g, Japh); # Japh

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://588010]
help
Chatterbox?
[ambrus]: The 0.2 seconds wakeup is likely a workaround for some bug, but I can't guess what bug that is.
[ambrus]: It's been there since Prima 1.00 iirc
[Corion]: Hmmm... Weird. Maybe it needs that for doing its timers or something. Still weird.
[Corion]: But I guess I'll find out soonish, as my application seems to use Prima for more than just displaying the OpenGL output soonish ;))
[ambrus]: No, I think the timers are handled fine in the event loop, as far as I can see.
[Corion]: So far, I liked Prima quite well as it simply seems to do what I want even if it has an upside-down coordinate system. But it installs from CPAN out of the box and is cross-platform

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2016-12-09 10:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (150 votes). Check out past polls.