Perl 6 Perl 6 today #49

Hyperoperators (vector processing)

Perl 5:

# pairwise add elements of @a and @b to produce @c
for ($i = 0; $i < @a; $i++) {
    $c[$i] = $a[$i] + $b[$i];
}

Perl 6 uses » and « to modify operators to become "hyper":

# pairwise add elements of @a and @b to produce @c
@c = @a »+« @b;

# increment all elements of @xyz
@xyz»++ ;

# @x is smallest of @a and @b
@x = @a »min« @b;
Copyright © 2009
http://www.pmichaud.com/2009/pres/