Skip to content

Instantly share code, notes, and snippets.

View colomon's full-sized avatar

Solomon Foster colomon

View GitHub Profile
# This is against current Math::Vector with method Dim changed to
# method Dim() is DEPRECATED('dim')
Wynne:Math-Vector colomon$ perl6 -Ilib --ll-exception t/01-basics.t
ok 1 - Variable is of type Math::Vector
ok 2 - Variable is of type Math::Vector
ok 3 - Variable is of type Math::Vector
ok 4 - Variable is of type Math::Vector
ok 5 - Variable is of type Math::Vector
ok 6 - Variable is of type Math::Vector
enum Results <success no-import hung crash>;
sub check-file($file) {
# say "working on $file";
my $proc = Proc::Async.new('utils/sat_nlib', $file);
$proc.stdout(:bin).tap: { Nil }
$proc.stderr(:bin).tap: { Nil }
await Promise.anyof(my $promise = $proc.start, Promise.at(now + 20));
enum Results <success no-import hung crash>;
sub check-file($file) {
# say "working on $file";
my $proc = Proc::Async.new('utils/sat_nlib', $file);
$proc.stdout(:bin).tap: { Nil }
$proc.stderr(:bin).tap: { Nil }
my $promise;
multi what's-that(42) { take 'The Answer' }
multi what's-that(Int $ where *.is-prime) { take 'Tis a prime!' }
multi what's-that(Numeric) { take 'Some kind of a number' }
multi what's-that($a, *@b where @b > 0) { what's-that($a); what's-that(|@b); }
multi what's-that { how-good-is $^it }
sub how-good-is ($) { take rand > ½ ?? 'Tis OK' !! 'Eww' }
my $seq := gather what's-that(1, 31337, 42, 'meows');
use v6;
use Inline::Python;
my $date = DateTime.now;
my %days-of-the-week := {
Monday => 1,
Tuesday => 2,
Wednesday => 3,
Thursday => 4,
Friday => 5,
use v6;
use File::Find;
sub is-git-top($dir) {
# shell('git rev-parse --is-inside-work-tree >&/dev/null').exitcode == 0;
# && shell('git rev-parse --is-inside-git-dir >&/dev/null').exitcode != 0;
$dir.child(".git").d;
}
sub Γ($x where $x > 0) {
$x > 2 ?? ($x - 1)*Γ($x - 1) !!
$x == 2 ?? 1 !!
1 / <
0.00000_00000_00000_00002 -0.00000_00000_00000_00023 0.00000_00000_00000_00141
0.00000_00000_00000_00119 -0.00000_00000_00000_11813 0.00000_00000_00001_22678
-0.00000_00000_00005_34812 -0.00000_00000_00020_58326 0.00000_00000_00510_03703
-0.00000_00000_03696_80562 0.00000_00000_07782_26344 0.00000_00001_04342_67117
-0.00000_00011_81274_57049 0.00000_00050_02007_64447 0.00000_00061_16095_10448
-0.00000_02056_33841_69776 0.00000_11330_27231_98170 -0.00000_12504_93482_14267
@colomon
colomon / fringe.p6
Created January 21, 2014 13:29 — forked from grondilu/fringe.p6
proto fringe($) { gather { {*} } }
multi fringe (Pair $node) { take fringe $_ for $node.kv }
multi fringe (Any $leaf) { take $leaf }
sub samefringe ($a, $b) { fringe($a) eqv fringe($b) }
my $a = 1 => 2 => 3 => 4 => 5 => 6 => 7 => 8;
my $b = 1 => (( 2 => 3 ) => (4 => (5 => ((6 => 7) => 8))));
my $c = (((1 => 2) => 3) => 4) => 5 => 6 => 7 => 8;
Program received signal SIGSEGV, Segmentation fault.
__strlen_sse2 () at ../sysdeps/x86_64/multiarch/../strlen.S:32
32 ../sysdeps/x86_64/multiarch/../strlen.S: No such file or directory.
(gdb) bt
#0 __strlen_sse2 () at ../sysdeps/x86_64/multiarch/../strlen.S:32
#1 0x00007ffff75b9d76 in __GI___strdup (s=0x0) at strdup.c:42
#2 0x00007ffff7a37c02 in uv_fs_lstat ()
from /home/colomon/tools/rakudo/install/lib/libmoar.so
#3 0x00007ffff79f8f99 in MVM_file_eof ()
from /home/colomon/tools/rakudo/install/lib/libmoar.so
sub has-converged($x, $y) {
abs($x-$y) < 1e-8*$y;
}
sub my-sqrt($n) {
my @approximations = 1, -> $x { 0.5 * ($x + $n/$x) } ... &has-converged;
@approximations[*-1];
}
for 1..10 -> $n {