reduce iterates over neighboring couples, i.e. one iteration less.
So each new iterator needs a new name ...
Lets suppose appending _couple instead of inventing individual names is sufficient.
first_couple {$a != $b} 0 ..9 any_couple ... map_couple ... ...
when letting $_ iterating normally with $^PRE activated you might want to add _ante everywhere
map_ante { $_ == $^PRE ? $_ : () } grep_ante ...
simply having special vars which only change behavior when they are used within the block, simplifies notation.
Even if one doesn't touch classical iterator names to guaranty backwards compatibility, already those three cases can be integrated into one naming convention:
xgrep { $_ == 9 } LIST # like ordinary grep xgrep { $a == $b } LIST # like grep_couple xgrep { $^PRE == $_ } LIST # like grep_ante xgrep { $a == $^PRE } LIST # ERROR xfirst ... # and so on
In other words orthogonality helps to keep the namespace slim. And I'm sure there are still other variants of special vars to be considered.
I promise to answer your other points soon, unfortunately I don't have the possibility at the moment...
Cheers Rolf
In reply to Re^6: reduce like iterators
by LanX
in thread reduce like iterators
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |