NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
refining the "show" function (Score:1)
sub show(%tree, Traversal $method) {
return unless %tree;
my @actions = (
{ show %tree<RIGHT>, $method },
{ show %tree<LEFT>, $method },
Re: (Score:1)
It's clearly a matter of taste of where you want to end up on the readability/non-repetitiousness scale. :) I simply chose to err on the side of readability this time around.
Re: (Score:1)
Re: (Score:1)
Am I the only one whose OCD goes on overdrive everytime he sees a fixed-function tree traversal sub?
I immediately want to refactor &show into a general traversal sub:
sub traverse(%tree, Traversal $order, &function) { ...
&function(%tree<VALUE>); ...
}
and a trivial driver:
sub show(%tree, Traversal $order) { traverse(%tree, $order, &take) }I guess that gets away from keeping the same overall form as the E02 code. Of course, I had the same reaction the first time I
Re: (Score:1)
Heh. The reaction I got on #perl6 was that I had changed the function too much by replacing
printbytake, essentially turning the&showfunction into an iterator generator.