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 | |
| parent | fc0acd318710aa0bb566329a36d886b1455c21ec (diff) | |
add hosts
Diffstat (limited to 'perl9.buetow.org/content/Extended-Features.sub')
7 files changed, 135 insertions, 0 deletions
diff --git a/perl9.buetow.org/content/Extended-Features.sub/Hypergoto.xml b/perl9.buetow.org/content/Extended-Features.sub/Hypergoto.xml new file mode 100644 index 0000000..5d910c7 --- /dev/null +++ b/perl9.buetow.org/content/Extended-Features.sub/Hypergoto.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?> +<content> + <pagetitle>Perl 9 supports hypergotos!</pagetitle> + <text>Perl 9 has the fastest goto ever! hypergoto is faster than everything you ve seen so far. A very fast loop can be programmed like this:</text> + <code> ++$counter+; +hypergoto ENDLOOP if $counter = 1000; +hypergoto LOOP; +ENDLOOP: +'End very fast goto'<-say; + </code> + <text>It is also possible to goto into different programs!</text> + <code> +hypergoto $pid, $routine, $instruction; + </code> + <text>...jumps into the process with the id $pid and the specified routine/instruction number.</text> +</content> diff --git a/perl9.buetow.org/content/Extended-Features.sub/Infinite-Loops.xml b/perl9.buetow.org/content/Extended-Features.sub/Infinite-Loops.xml new file mode 100644 index 0000000..d8658b7 --- /dev/null +++ b/perl9.buetow.org/content/Extended-Features.sub/Infinite-Loops.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?> +<content> + <pagetitle>Perl 9 has now infinite loops!</pagetitle> + <text>Perl 9 supports an infinite loop which needs only 1 second of runtime. Which is faster than every other language needs to do this. This is possible because of very modern algorithms of the Perl 9 internals.</text> + <code> +#!/usr/bin/perl9 + +my $pi; +infinite { + $pi = calculate_pi; + say $pi; # Prints out THE EXACT number Pi! +} + + +# Will need infinite time to print Pi because not in the infinite loop! +say $pi; + </code> + <text>It is also possible to run several infinite loops in parallell using threads!</text> + <code> +my $pi; +my $code1 = infinite { + $pi = calculate_pi; + say $pi; # Prints out THE EXACT number Pi! +} +my $euler; +my $code2 = infinite { + $euler = calculate_euler; + say $euler; # Prints out THE EXACT number euler! +} + +Thread.new(code => $code1).run; +Thread.new(code => $code2).run; + </code> +</content> 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> diff --git a/perl9.buetow.org/content/Extended-Features.sub/Mixed-Contexes.xml b/perl9.buetow.org/content/Extended-Features.sub/Mixed-Contexes.xml new file mode 100644 index 0000000..d6b2feb --- /dev/null +++ b/perl9.buetow.org/content/Extended-Features.sub/Mixed-Contexes.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?> +<content> + <pagetitle>Perl 9 can now mix up contexes!</pagetitle> + <text>As you know from previous versions of Perl, you use the contexes void, list and scalar to program in. Now you are able to mix those together within the same variable!</text> + <code> +my $@scaarr = ("Hello", (1, 2, 3, 4)); +$@scaarr.scalar.say; # Prints Hello +local $, = ' '; $@scaarr.say; # Prints 1 2 3 4 + </code> +</content> diff --git a/perl9.buetow.org/content/Extended-Features.sub/Random-Number-Generator.xml b/perl9.buetow.org/content/Extended-Features.sub/Random-Number-Generator.xml new file mode 100644 index 0000000..ff8148a --- /dev/null +++ b/perl9.buetow.org/content/Extended-Features.sub/Random-Number-Generator.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?> +<content> + <pagetitle>Real random number generator!</pagetitle> + <text>Perl 9 now has got a REAL random number generator. No more psydo random generators. The perl process goes outside of your computer and looks for some random stuff to capture. Here is an example:</text> + <code> +random(10).say; # Prints out a real random number >=0 and < 10 + </code> +</content> diff --git a/perl9.buetow.org/content/Extended-Features.sub/Reverse-Methods.xml b/perl9.buetow.org/content/Extended-Features.sub/Reverse-Methods.xml new file mode 100644 index 0000000..9df5b41 --- /dev/null +++ b/perl9.buetow.org/content/Extended-Features.sub/Reverse-Methods.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?> +<content> + <pagetitle>Perl 9 has now reverse method operators!</pagetitle> + <text>You don't have to call $object.method or $object->method any more! You can also do method<-$object instead! This leads to a new level of flexibility and programming experience!</text> + <code> +#!/usr/bin/perl9 + +your $result = 1->add(1) / mult(2)<-2; +say<-$result; # Will print 0.5 + </code> +</content> diff --git a/perl9.buetow.org/content/Extended-Features.sub/home.xml b/perl9.buetow.org/content/Extended-Features.sub/home.xml new file mode 100644 index 0000000..1826442 --- /dev/null +++ b/perl9.buetow.org/content/Extended-Features.sub/home.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?> +<content> + <pagetitle>Perl 9 has improved old techniques</pagetitle> + <text>Here are the most exciting feature extendings of Perl 9 listed. Just click on the top menu on the desired feature and you will see the examples!</text> +</content> |
