H
hofer
Hi,
I know I can live without it or with a self written iterator
or . . . , but would still like to know
other perlish ways
creating an array with numbers from 0 to 9 i would use
@a = (0...9);
for the reverse
@a = reverse(0..9);
cycling trough 0 to n (n verly large)
I'd do
$n=100000;
foreach $v (0..$n){ dowith($v) }
# If I understood well the (0..$n) would NOT create a list, but act as
iterator
for the reverse I'd hesitate to use reverse() as it creates probably
the entire list first
so I'd do either
foreach $v_up (0..$n) { $v_down = $n-$v; dowith($v); }
or foreach( $v=$n;$v>=0;$v--){ dowith($v); }
Does anybody have a 'nicer' way ?
I know I can live without it or with a self written iterator
or . . . , but would still like to know
other perlish ways
creating an array with numbers from 0 to 9 i would use
@a = (0...9);
for the reverse
@a = reverse(0..9);
cycling trough 0 to n (n verly large)
I'd do
$n=100000;
foreach $v (0..$n){ dowith($v) }
# If I understood well the (0..$n) would NOT create a list, but act as
iterator
for the reverse I'd hesitate to use reverse() as it creates probably
the entire list first
so I'd do either
foreach $v_up (0..$n) { $v_down = $n-$v; dowith($v); }
or foreach( $v=$n;$v>=0;$v--){ dowith($v); }
Does anybody have a 'nicer' way ?