Perl 6 Hints
@perl6hints
Small code examples, useful Perl 6 tricks, tips and interesting programming techniques.
You might like
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 ''; }
This #Perl6 code will display poetry! Source & 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
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!
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
United States Trends
- 1. #WorldSeries 109K posts
- 2. Dodgers 135K posts
- 3. Ohtani 96.6K posts
- 4. Kershaw 16.6K posts
- 5. Mookie 11.9K posts
- 6. Freddie 15.8K posts
- 7. Will Smith 13.2K posts
- 8. Tommy Edman 4,730 posts
- 9. Lauer 2,326 posts
- 10. Draymond 6,314 posts
- 11. Joe Davis 1,443 posts
- 12. Vladdy 8,835 posts
- 13. Marlins 1,289 posts
- 14. Klein 156K posts
- 15. Inning 15 1,084 posts
- 16. Dave Roberts 4,116 posts
- 17. Alex Call 1,507 posts
- 18. #Worlds2025 5,521 posts
- 19. Lukes 2,814 posts
- 20. Wikipedia 47.2K posts
Something went wrong.
Something went wrong.