Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Golf/Perlish solution to this problem?

by thospel (Hermit)
on Jan 31, 2008 at 08:34 UTC ( #665305=note: print w/replies, xml ) Need Help??


in reply to Golf/Perlish solution to this problem?

Without going for total golf (tempting, but I can resist) I'd still write something like:
my $n = 8; my $i = 1; my @array; push @array, $n--, $i++, $i++, $n-- while $n > $i; print "@array";
This breaks the rule of not increasing/decreasing the same variable twice in the same statement, but in practise this will work in all versions of perl5. Notice that in fact it wouldn't work if pre-increment/pre-decrement had been used instead of post-increment/post-decrement

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2021-01-15 20:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?