Skip to content

Instantly share code, notes, and snippets.

Matthew Wilson diakopter

Block or report user

Report or block diakopter

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@diakopter
diakopter / Printf.idr
Created Jul 23, 2019 — forked from chrisdone/Printf.idr
Type-safe dependently-typed printf in Idris
View Printf.idr
module Printf
%default total
-- Formatting AST.
data Format
= FInt Format
| FString Format
| FOther Char Format
| FEnd
View gist:949e318aa0378e7da1004b103b287036
use MONKEY-TYPING;
augment class Any {
method foo {
say "hello world";
}
}
"blah".foo;
View gist:7981dc5b1d0ff7598e53
my $compile-time-sub;
sub call-compile-time-sub() is export { note 'before'; $compile-time-sub(); note 'after'; }
BEGIN { $compile-time-sub = -> { <.so .dll .dylib>.map("lib/" ~ *); }; }
call-compile-time-sub()
View gist:a97355932b4f06f4fb6e
use v6;
=begin pod
=TITLE Simple Infix Arithmetic Calculator
=AUTHOR Yichun Zhang
Operators supported: +, -, *, /, and ^.
View gist:62f8f31f8b2e40298896
sub postfix:<!> (Int $n) {
fail "Not a Natural Number in Factorial" if $n < 0;
[*] 2..$n
}
use Test;
isa-ok (-1)!, Failure, "Factorial for -1 fails";
ok 0! == 1, "Factorial for 0";
ok 1! == 1, "Factorial for 1";
ok 5! == 120, "Factorial for a larger integer";
View foo.p6
class TreeNode {
has Int $!item;
has TreeNode $!left;
has TreeNode $!right;
method spawn(Int \item, Int \depth) {
return ChildTreeNodes(item, depth - 1);
}
View gist:8471d586ad73e3516f0f
C:\Users\mwilson\src\rakudo>"C:\Users\mwilson\src\rakudo\install\bin\moar" --execname="perl6-m" --libpath="C:\Users\mwilson\src\rakudo\install\share\nqp\lib" --libpath="." C:\Users\mwilson\src\rakudo\perl6-debug.moarvm --ll-exception t\04-nativecall\01-argless.t
>>> LOADING t\04-nativecall\01-argless.t
>>> LOADING C:\Users\mwilson\src\rakudo\t\04-nativecall\CompileTestLib.pm
+ C:\Users\mwilson\src\rakudo\t\04-nativecall\CompileTestLib.pm (1 - 3)
| unit module CompileTestLib;
|
| my @cleanup; # files to be cleaned up afterwards
>
Too many positionals passed; expected 1 argument but got 2
at gen/moar/m-Metamodel.nqp:2779 (./blib/Perl6/Metamodel.moarvm:new:0)
View irc-test.p6
use v6;
my $chan = '#perl6';
await IO::Socket::Async.connect('irc.freenode.net',6667).then( -> $p {
my $sock = $p.result;
$sock.print("NICK P6\nUSER P6 Perl6 work :Perl6 Perl6\nJOIN $chan\n");
my $timer = Promise.in(3).then({ now });
react {
whenever $timer -> $now {
say "Now is $now\n";
$sock.print: ":P6!P6\@work PRIVMSG $chan : diakopter Now is $now\n";
View gist:a280c203bc1bbc871fd8
Test Summary Report
-------------------
t/04-nativecall/02-simple-args.t (Wstat: 256 Tests: 12 Failed: 1)
Failed test: 11
Non-zero exit status: 1
t/04-nativecall/03-simple-returns.t (Wstat: 256 Tests: 11 Failed: 1)
Failed test: 3
Non-zero exit status: 1
t/04-nativecall/13-union.t (Wstat: 768 Tests: 28 Failed: 3)
Failed tests: 2, 15, 24
View gist:97af59d05b56140ac762
>>> Bash: bash test/test.bash
Igpay atinlay
Ingystray ingythay
Iway Ikelay Applesway
PASS
>>> C++: g++ -o test/test-cpp test/test.cpp && test/test-cpp
Igpay atinlay
Ingystray ingythay
Iway Ikelay Applesway
You can’t perform that action at this time.