in reply to Re: Playing with (macro/source-filter) fire
in thread Playing with (macro/source-filter) fire
And here's the result of Recur_unroll...my $x; $x = 0;{my $f = fact($x); print "factorial($x)=$f\n";} $x++;{my $f = fact($x); print "factorial($x)=$f\n";} $x++;{my $f = fact($x); print "factorial($x)=$f\n";} $x++;{my $f = fact($x); print "factorial($x)=$f\n";} $x++;{my $f = fact($x); print "factorial($x)=$f\n";} $x++;{my $f = fact($x); print "factorial($x)=$f\n";} $x++;{my $f = fact($x); print "factorial($x)=$f\n";} $x++;{my $f = fact($x); print "factorial($x)=$f\n";} $x++;sub fact { $_[0] <= 0 and return 1; return $_[0] * fact($_[0] - 1); }
my $x; $x = 0; while ($x < 8) { my $f = fact($x); print "factorial($x)=$f\n"; } continue { ++$x } sub fact { $_[0] <= 0 and return 1; return $_[0] * eval{local @_=$_[0] - 1; $_[0] <= 0 and return 1; return $_[0] * fact($_[0] - 1); }; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Playing with (macro/source-filter) fire
by stvn (Monsignor) on Jan 23, 2004 at 21:15 UTC |