diff options
| author | Paul Buetow <paul@buetow.org> | 2013-02-03 10:44:49 +0100 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2013-02-03 10:44:49 +0100 |
| commit | 025e15b2ba7f54f87cf409fd7c3dd77746c72858 (patch) | |
| tree | 007c5af4f921aa85665f4db56f6f4309668a5dab /perl9.buetow.org/content/Extended-Features.sub/Megahyper-Operators.xml | |
| parent | fc0acd318710aa0bb566329a36d886b1455c21ec (diff) | |
add hosts
Diffstat (limited to 'perl9.buetow.org/content/Extended-Features.sub/Megahyper-Operators.xml')
| -rw-r--r-- | perl9.buetow.org/content/Extended-Features.sub/Megahyper-Operators.xml | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/perl9.buetow.org/content/Extended-Features.sub/Megahyper-Operators.xml b/perl9.buetow.org/content/Extended-Features.sub/Megahyper-Operators.xml new file mode 100644 index 0000000..7bcd5a1 --- /dev/null +++ b/perl9.buetow.org/content/Extended-Features.sub/Megahyper-Operators.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?> +<content> + <pagetitle>Hyper- mega hyper and mega mega hyper!</pagetitle> + <text>You probably already know the so called Hyperoperators of Perl 6!</text> + <code> +# This code +my @baz = @foo >>+<< @bar; + +# Is the same as: +loop ($i = 0; $i < @bar.elems; ++$i) { + push @baz, @foo[$i] + @bar[$i]; +} + </code> + <text>A mega hyper operator takes you to the next level:</text> + <code> +# This code +my @baz = @foo >>>>+<<<< @bar; + +# Is the same as: +loop ($i = 0; $i < @bar.elems; ++$i) { + my $foo = @foo[$i]; + my $bar = @bar[$i]; + my $baz = @baz[$i]; + loop ($j = 0; $j < $bar->elems; ++$j) { + push @$baz, $foo->[$j] + $bar->[$j]; + } +} + </code> + <text>And a mega mega hyper operator does this:</text> + <code> +# This code +my @baz = @foo >>>>>>+<<<<<< @bar; + +# Is the same as: +loop ($i = 0; $i <&t; @bar.elems; ++$i) { + my $foo = @foo[$i]; + my $bar = @bar[$i]; + my $baz = @baz[$i]; + loop ($j = 0; $j < $bar->elems; ++$j) { + my $foo_ = $foo->[$j]; + my $bar_ = $bar->[$j]; + my $baz_ = $baz->[$j]; + loop ($k = 0; $k < $bar_->elems; ++$k) { + push @$baz_, $foo_->[$k] + $bar_->[$k]; + } + } +} + </code> + <text>Etc... As you can see, its helping you to write less code!</text> +</content> |
