Skip to content

Instantly share code, notes, and snippets.

View fake-trust.raku
use v6.d;
class A {
has $!a = 'private';
method !a { $!a }
}
multi sub trait_mod:<is>(Mu:U \obj, :$spying!) {
A.^add_trustee(obj);
A.^compose;
View stealth-iterables.raku
my @types =
Q{AST},
Q{Allomorph},
Q{Any},
Q{Array},
Q{Associative},
Q{Attribute},
Q{Awaitable},
Q{Awaiter},
Q{Backtrace},
View gist:0df500d560d3e59a2360162a3a3bad6a
class C {
multi method m(Int $i) { $i + 1 }
}
C.^methods.classify(*.name)<m>[0].add_dispatchee(my method m(Int() $i) { self.m($i) });
C.new.m("41").say;
View parallel-shifty.raku
use v6.d;
class Shifty does Positional does Iterable {
has Channel:D $.channel is required;
has $.open is rw = True;
method shift {
LEAVE $.open = False if self.channel.closed;
self.channel.receive;
}
method iterator {
View hyperize.raku
use v6.*;
{
multi sub hyperize(&code, '«') {
sub (@little, @large) {
((@little xx *).flat Z @large).flat.map(&code)
}
}
my &hyper-assume = hyperize({&^a.assuming($^b)}, '«');
View hyperize.raku
use v6.*;
{
multi sub hyperize(&code, '«') {
sub (@little, @large) {
((@little xx *).flat Z @large).flat.map(&code)
}
}
my &hyper-assume = hyperize({&^a.assuming($^b)}, '«');
View #raku-beginner.log
--- Log opened Mon Aug 16 16:37:02 2021
16:37 -!- gfldex [~dex@ip5f5ab722.dynamic.kabel-deutschland.de] has joined #raku-beginner
16:37 [Users #raku-beginner]
16:37 [@lizmat] [ gfldex]
16:37 -!- Irssi: #raku-beginner: Total of 2 nicks [1 ops, 0 halfops, 0 voices, 1 normal]
16:37 -!- Channel #raku-beginner created Mon Aug 16 16:35:55 2021
16:37 -!- Irssi: Join to #raku-beginner was synced in 0 secs
16:37 -!- lizmat changed the topic of #raku-beginner to: This channel is intended for people just starting with the Raku Programming Language (https://raku.org).
16:39 -!- RakuIRCLogger [~RakuIRC@ipv4-wenzperl.connected.by.freedominter.net] has joined #raku-beginner
16:40 -!- dakkar [~dakkar@host-87-5-114-102.retail.telecomitalia.it] has joined #raku-beginner
View pentathing.raku
#! /usr/bin/env -S raku --profile=pentathing-profile.html
use v6.*;
sub is-pentagon($c is raw) { (1+sqrt(1+24*$c))%%6 }
sub P($n is raw) { $n*(3*$n-1) div 2 }
my atomicint $bail = 0;
(^∞).hyper(:batch(64)).map( -> \b {
last if $bail;
View pentathing.raku
#! /usr/bin/env raku
#! /usr/bin/env -S raku --profile=pentathing-profile.html
sub is-pentagon($c) { (1+sqrt(1+24*$c))%%6 }
sub P($n) { $n*(3*$n-1)/2 }
my int $bigger = 1;
BAIL: loop {
$bigger++;
View 2021-03-08.raku
use v6.*;
# my $a = '1 B';
#
# if $a ~~ /(<digit>) \s (<alpha>)/ -> $_ {
# my ($one, $B) = .deepmap: *.Str;
# say "$one $B";
# }
#
# if $a ~~ /(<digit>) \s (<alpha>)/ -> Match (Str() $one, Str() $B) {