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
multi quicksort([]) { Empty } | |
multi quicksort([$pivot, *@rest]) { | |
my (:@Less, :@Same, :@More) := @rest.classify(* cmp $pivot); | |
[ |quicksort(@Less), $pivot, |@Same, |quicksort(@More) ] | |
} | |
say quicksort [7, 2, 1, 8, 1, 9, 3] |
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
multi quicksort([]) { Empty } | |
multi quicksort([$pivot, *@rest]) { | |
my %list{Order} is default([]) = @rest.classify: * cmp $pivot; | |
[ |quicksort(%list{Less}), $pivot, |%list{Same}, |quicksort(%list{More}) ] | |
} | |
say quicksort [7, 2, 1, 8, 1, 9, 3] |
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
enum Area <kanto johto hoenn sinnoh unova kalos alola>; | |
event Hot { | |
has Str $.type where * eq "temperature"; | |
has Area $.area; | |
has Int $.value where * > 40; | |
} | |
event Dry { | |
has Str $.type where * eq "humidity"; |
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
#!/usr/bin/env raku | |
use v6.e.PREVIEW; | |
# Bla.^all.map: { $_ + 1 }; | |
say [1,2,3].map: { $_ + 1 }; | |
CHECK { | |
sub translate-rakuast-to-redast($raku) { | |
return RakuAST::IntLiteral.new: 42 |
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
➜ Nats git:(main) nats pub --count=10 bla.ble.bli "test pub {{ Count }}" | |
19:58:50 Published 10 bytes to "bla.ble.bli" | |
19:58:50 Published 10 bytes to "bla.ble.bli" | |
19:58:50 Published 10 bytes to "bla.ble.bli" | |
19:58:50 Published 10 bytes to "bla.ble.bli" | |
19:58:50 Published 10 bytes to "bla.ble.bli" | |
19:58:50 Published 10 bytes to "bla.ble.bli" | |
19:58:50 Published 10 bytes to "bla.ble.bli" | |
19:58:50 Published 10 bytes to "bla.ble.bli" | |
19:58:50 Published 10 bytes to "bla.ble.bli" |
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 Cro::HTTP::Client; | |
use Red; | |
model ChatGPTConversation { | |
has Int $.id is serial; | |
has Str $.question is column; | |
has Str $.answer is column; | |
} | |
sub chat_with_gpt($prompt) { |
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
my @children-names = <Fernanda Sophia Eduardo Rafael Maria Lulu>; | |
my @countries = <Brazil England Scotland>; | |
factory "child", :model(Child), { | |
.name = { "{ @children-names.pick } { .counter-by-model }" }; | |
.country = { @countries.pick }; | |
} |
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; | |
use Factories; # your factories module | |
use Child::Helper; # imports &children-on-country | |
factory-run { | |
is children-on-country("UK"), 0; | |
.create: "child", :country<UK>; | |
is children-on-country("UK"), 1; | |
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 Factories; # your factories module | |
factory-run { | |
my $child = .create: "child"; | |
} |
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 Factories; # your factories module | |
my $*RED-DB = factory-db; | |
my $child = factory-create "child"; |