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
In reply to Re^3: An infix fix
by tlm
in thread An infix fix
by tlm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |