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 class a { | |
has @.b; | |
method get-flat { @!b.map(|*.get-flat); } | |
method p { | |
say 'A: ', WHAT $.get-flat; | |
# why doesn't this loop act like D: below? | |
for self.get-flat() -> $c { | |
say 'B: ', $c.perl | |
} | |
} |
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 sub infix:<+>(Unit $x, Unit $y) { | |
if (not $x.isSameUnit($y)) {die "Units do not match.";} | |
return Unit.new(magnitude => $x.magnitude + $y.magnitude, units => $x.units); | |
} | |
my $a = Units::Unit.new(magnitude => 1.2, units => ("m" => 1)); | |
my $b = Units::Unit.new(magnitude => 5.0, units => ("m" => 1)); | |
say $a + $b; |
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 nqp; | |
{ | |
constant $read-file = "README.md".IO; | |
$read-file.IO.r; | |
for ^1000 { | |
my $p = Proc::Async.new( | «/bin/cat $read-file» ); | |
my $output = ''; | |
$p.stdout.tap: -> $s { $output ~= $s; }; | |
await $p.start; |
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 nqp; | |
my $html; | |
my $proc = run "wget", "-o", "/dev/null", "-O", "-", "https://www.fimfiction.net/bookshelf/149291/", :out; | |
$html = $proc.out.slurp-rest; | |
say "html is " ~ $html.chars ~ " chars"; | |
nqp::force_gc; | |
say "/proc/$*PID/statm".IO.lines[0].split(/\s/)[5] * 4096 / 1024 |
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 perl6 | |
use lib ‘data/all-modules/softmoth/p6-Template-Mustache’; | |
use v6; | |
#use v6.d.PREVIEW; | |
use Template::Mustache; | |
my $html = q:to/EOF/; | |
<html> | |
{{> head }} |
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 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
if[^{]+=(?!=)[^{]+\{ |
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 v6; | |
my Int @cache is default(0); | |
my $sum89 = 0; | |
for (1..567) -> $i { | |
@cache[$i] = calc-chain($i); | |
} | |
for (1..400_000) -> $i { |
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 Slang::Tuxic; | |
#use Text::CSV; | |
#use File::Find; | |
my $csv_line = ‘foo’; # Text::CSV.new (eol => "\n"); | |
my $cols = 49; | |
my @IO-object-list = < a b c >; #find(:dir</home/user1/documents/animals>, :type<file>, :name(/armadillos_201<[4..8]>.*\.csv/)); | |
for @IO-object-list -> $IO-object { |
OlderNewer