in reply to Golf Question - Shortest way to write while inside while
If you want to use lots of whiles in a code, define a sub. For example (untested):
or, likesub w (\&@) { while (&{$_[0]}()) { &{$_[1]}() } } sub d (\&) { $_[0]; } # then, instead of while (foo) { bar }, you can say w{foo}d{bar};
sub l(\&) { WHILE: while(1) { &{$_[0]}(); } } sub w($) { $_[0] or last WHILE } # then, instead of while (foo) { bar }, l{w foo;bar};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Golf Question - Shortest way to write while inside while
by ikegami (Patriarch) on Nov 08, 2007 at 09:42 UTC | |
by ambrus (Abbot) on Nov 08, 2007 at 10:16 UTC |