in reply to generating pyramid number sequence

as much as it pains me to use a c style for....
my $n=7; for my $a ( 1.. $n-1){ for( my $b = 1; $b+$a <= $n; $b++){ print $b, ',', $b+$a, ' '; } print "\n"; }

Replies are listed 'Best First'.
Re^2: generating pyramid number sequence
by duckyd (Hermit) on Jan 20, 2006 at 02:19 UTC
    ah, this is more perlish:
    my $n=7; for my $a ( 1..$n-1){ print $_, ',', $_+$a, ' ' for (1..$n-$a); print "\n"; }
      Maybe this one is more "perlish" but the first one you posted is certainly easier to read!