summaryrefslogtreecommitdiff
path: root/perl9.buetow.org/content/Extended-Features.sub/Megahyper-Operators.xml
diff options
context:
space:
mode:
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.xml50
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 &gt;&gt;+&lt;&lt; @bar;
+
+# Is the same as:
+loop ($i = 0; $i &lt; @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 &gt;&gt;&gt;&gt;+&lt;&lt;&lt;&lt; @bar;
+
+# Is the same as:
+loop ($i = 0; $i &lt; @bar.elems; ++$i) {
+ my $foo = @foo[$i];
+ my $bar = @bar[$i];
+ my $baz = @baz[$i];
+ loop ($j = 0; $j &lt; $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 &gt;&gt;&gt;&gt;&gt;&gt;+&lt;&lt;&lt;&lt;&lt;&lt; @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 &lt; $bar->elems; ++$j) {
+ my $foo_ = $foo->[$j];
+ my $bar_ = $bar->[$j];
+ my $baz_ = $baz->[$j];
+ loop ($k = 0; $k &lt; $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>