Thomas Chust wrote:
> Hello,
> looking into Perl 6 syntax I noticed that there are meta- and
> hyperoperators to perform among others the classical functional map
> and fold operations. However, if I understood this correctly, you can
> only use these constructs to lift scalar *operators* to the domain of
> arrays.

For operators there are meta-operators. For functions there are functions:

reduce &reduce_function, map &map_function @values;

Note that the biggest advantage of things like [**] is that they
automatically obey the associativity rules for the operator infix:<**>.
Since subs have no associativity, I don't see a big advantage in having
a reduce-for-functions or map-for-functions operator.

> Therefore I think that it would be a nice addition for Perl 6 if the
> X...X, <<...>> and similar operators could be applied to anonymous
> subroutines in addition to other operators. If such a syntactic change
> wasn't possible it would probably be worthwhile to offer methods like
> map and fold on array instances that take subroutine references as an
> alternative.

There are already. You could write my example above also as


Moritz Lenz
http://perlgeek.de/ |  http://perl-6.de/ | http://sudokugarden.de/

Reply via email to