in reply to Re^2: An infix fix
in thread An infix fix
Come to think of it, none of these recursive subs are tail recursive. They all have a pending && or || business when they return.
I can't think of a simple way to make them tail recursive. The best I can come up with requires using "helper functions":
sub OR { _OR (0, @_) } sub AND { _AND(1, @_) } sub _OR { my $s = shift; @_ && !$s ? _OR ( $s || shift, @_ ) : $s } sub _AND { my $s = shift; @_ && $s ? _AND( $s && shift, @_ ) : $s }
the lowliest monk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: An infix fix
by Roy Johnson (Monsignor) on Mar 22, 2005 at 23:30 UTC |