good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Why does the block use $^a in one place (the automatic parameter) and $a in another place? Shouldn't that be a different (undeclared) variable? (Likewise for b).
If you move the uc you can avoid copying the whole string. Not much savings for a small string I suppose, but you break the clean pipeline nature by copying the input first, rather than doing nothing more than passing each character through the pipeline. Here's a shaken-up version, starting with noticing how the list return of a for loop is similar to the map function: sub infix:<ↀ> ($a,$b) { $a+$b-$a%$b*2 } [ↀ] do for $x.split('') { %rtoa{$_.uc} }and an excuse to show off the cool form of the reduction metaoperator. P.S.: used pre instead of code because Perl Monks still doesn't like Unicode. code escapes out the entities, and the form isn't submitted in UTF-8 so various things are automatically encoded. Nasty. In reply to Re^2: Rosetta PGA-TRAM
by John M. Dlugosz
|
|