This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://docs.raku.org/language/typesystem#subset | |
# A subset gives us a thing we can smartmatch ( ~~ ) against | |
# at which point the where condition gets executed on the thing we | |
# are smartmatching. | |
# | |
# For example: | |
# subset StartsWithA of Str where *.starts-with("A"); | |
# say "Brussels Sprouts" ~~ StartsWithA; # False | |
# say "Antonio Banderas" ~~ StartsWithA; # True | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Test; | |
my @M = | |
[ 1, 2, 3, 5, 7 ], | |
[ 9, 11, 15, 19, 20 ], | |
[ 23, 24, 25, 29, 31 ], | |
[ 32, 33, 39, 40, 42 ], | |
[ 45, 47, 48, 49, 50 ]; | |
# A multi sub implementing a binary search. multi subs are a mechanism |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Raku feature: Lazy list. This construct will repeat 99 to 0 | |
# and then start over at 99 ad infintum when iterated | |
my @bottles = flat (99...0) xx Inf; | |
# for every index, generate the "xx bottles of beer" | |
# when using double quotes the Raku parser interprets | |
# code in curlies as, well, code and embeds the return | |
# value within the string | |
# in the first block we see an ordinary logical or |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
subset NonEmptyStr of Str where *.chars > 0; | |
subset FastaStr of Str where * ~~ / ^ <[ ACGT ]>+ $/; | |
subset ReadableFile where { .IO.e && .IO.f && .IO.r }; | |
class Fasta::Sequence | |
{ | |
has NonEmptyStr $.data is required; | |
has NonEmptyStr $.description is required; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The most common approach, and probably the simplest solution to this challenge | |
# is to create an array of men, and then keep taking two from the front and putting the first of | |
# them to the back of the array until it has only one member left. | |
# | |
# A concise version of this looks like | |
sub take-two-push-one | |
{ | |
given my @men = 1..50 { .push( .splice(0,2).first ) while .elems > 1 }; | |
@men.first; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# People don't learn about this anymore | |
role Linked { has $.next is rw; } | |
my $first = my $killer = 1 but Linked; | |
for 2..50 { my $man = $_ but Linked; $killer.next = $man; $killer = $man; } | |
$killer.next = $first; | |
$killer = $first; | |
while $killer != $killer.next { | |
$killer = $killer.next = $killer.next.next; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
".source.perl6, .source.perl6fe": { | |
"script": { | |
"prefix": "script", | |
"body": "#!/usr/bin/env perl6\n\nuse v6;\n\nsay \"Hello world\";" | |
}, | |
"pod": { | |
"prefix": "pod", | |
"body": "=begin pod\n$1\n=end pod" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install tput | |
> echo 'tput reset'>cls | |
> chmod 755 cls | |
> mv cls /usr/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This code | |
my $bookFile ="2774.epub"; | |
my $bookUrl = "http://93.174.95.27/foreignfiction/get.php?md5=5d3ef26e36584edd9b2434deaced6a55&key=3XD005UYYM2SP81G"; | |
say qq[curl -o $bookFile "$bookUrl"]; | |
shell qq[curl -o $bookFile "$bookUrl"]; | |
#when run it produces the error. note the extra quote ( ""http" ) | |
D:\P6>perl6 t.p6 | |
curl -o 2774.epub "http://93.174.95.27/foreignfiction/get.php?md5=5d3ef26e36584edd9b2434deaced6a55&key=3XD005UYYM2SP81G" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; mwo-auto-launch | |
; Version 0.2 | |
; | |
; by Markus "Tailgunner" Holzer | |
; | |
; This script launches the Mechwarrior Online Client | |
; and eliminates the tedious need to enter your password every time | |
; to play. | |
; | |
; To make it work you will need to edit this script and change some values so it works on your system. |