perl6hints's profile picture. Small code examples, useful Perl 6 tricks, tips and interesting programming techniques.

Perl 6 Hints

@perl6hints

Small code examples, useful Perl 6 tricks, tips and interesting programming techniques.

PERL in a Browser?! Now it is possible to run Perl directly from the browser! No server requests. Just webperl using webassembly Try yourself: js.do/perl/ See details about this incredible project: webperl.zero-g.net #webperl

perl6hints's tweet image. PERL in a Browser?! Now it is possible to run Perl directly from the browser! No server requests. Just webperl using webassembly
Try yourself: js.do/perl/
See details about this incredible project: webperl.zero-g.net
#webperl

"If you have the right attitude, interesting problems will find you." (from "19 Lessons for Creating Good Software") bit.ly/2aZIXrn


Really easy to install and use #Perl6 for Windows: 1. Download and install bit.do/perl6win 2.Type "perl6" at start button 3.Have fun


#Perl6 circle equation for (-25..25)X(-25..25) ->($y,$x){ print (16² <$x²+$y² <20²)??'o'!!'.'; $x==25 && say ''; }

perl6hints's tweet image. #Perl6 circle equation
for (-25..25)X(-25..25) -&amp;gt;($y,$x){
 print (16² &amp;lt;$x²+$y² &amp;lt;20²)??&apos;o&apos;!!&apos;.&apos;;
 $x==25 &amp;amp;&amp;amp; say &apos;&apos;;
}

This #Perl6 code will display poetry! Source & explanation: github.com/rsiqueira/perl… Code excerpt: say 128514.uniname

perl6hints's tweet image. This #Perl6 code will display poetry!
Source &amp;amp; explanation: github.com/rsiqueira/perl…
Code excerpt:
say 128514.uniname

Learn #Perl6 the easy way with perl6intro.com All in a single page. Great place to start learning.Including functional programming!


How to list and sort all unique words from a text file using #Perl6: for "myfile.txt".IO.words.unique.sort -> $word { say $word; }


More #Perl6 #Unicode say "⁂".uniname; # It will print "ASTERISM" say "\c[SKULL]"; # It will print "💀" say "\x263a"; # ☺ prints Smiling Face


#Perl6 #Unicode ("α".."ω").list; # Prints Greek alphabet say π³; # same as say pi**3 say (1,2,3,4) ∩ (2,4,6,8); # intersection is set(2,4)


#Perl6 Shortest #Mandelbrot code ever!!! 89 chars: for ^50 X ^72 ->($y,$x){my$z=!$x&&say %;$z=$z²+($x+$y*i)/25-2-i for ^9;print +($z.abs>4)}


"The elegance of Perl is why I fell in love with it." #Perl quote of the day, by @ultimape #perl6 #quotes


#Perl6 to print all #primenumbers: for 0..Inf -> $n { $n.say if $n.is-prime } # Using implicit variable: for 0..Inf { .say if .is-prime }


#Perl6 #Mandelbrot for ^40 -> $y {for ^72 {my $z=0;my $i=50;while (--$i&&$z.abs<4) { $z=$z*$z+$_/36-1.5+$y\i/20-i};print $i%9||'.'};say ""}


The Mandelbrot set #fractal complete algorithm implemented in less than 140 chars with #Perl6 native Complex Numbers

perl6hints's tweet image. The Mandelbrot set #fractal complete algorithm implemented in less than 140 chars with #Perl6 native Complex Numbers

A joke in #perl6. This sub really returns a random number. sub random { return [4] } say random(); # Magic: sub circumfix:<[ ]> (4) { rand }


" #Perl6 is a ridiculously powerful multi-paradigm language that makes writing code an utter pleasure again. "

Our very first #blog post of 2016: Happy New #Perl6 Released! blog.builtinperl.com/post/happy-new… Kudos to the entire team!

BuiltinPerl's tweet image. Our very first #blog post of 2016: Happy New #Perl6 Released! blog.builtinperl.com/post/happy-new… Kudos to the entire team!


Reduction Operator [+] will sum all elements of the following array. say [+] 2,3 (will display "5"). say [*] 2,3 (is 6). say [~] 2,3 (is 23)


Now it is possible! A summation function using the sigma Σ notation (unicode greek letter as a #Perl6 function).

My first PERL6 program: sub Σ(@array_to_sum) { return [+] @array_to_sum; } say Σ (1,2,3,4); # It will display 10



Loading...

Something went wrong.


Something went wrong.