Skip to content

Instantly share code, notes, and snippets.

View diakopter's full-sized avatar
💭
🤠

Matthew Wilson diakopter

💭
🤠
View GitHub Profile
@diakopter
diakopter / Printf.idr
Created July 23, 2019 23:44 — forked from chrisdone/Printf.idr
Type-safe dependently-typed printf in Idris
module Printf
%default total
-- Formatting AST.
data Format
= FInt Format
| FString Format
| FOther Char Format
| FEnd
use MONKEY-TYPING;
augment class Any {
method foo {
say "hello world";
}
}
"blah".foo;
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()
use v6;
=begin pod
=TITLE Simple Infix Arithmetic Calculator
=AUTHOR Yichun Zhang
Operators supported: +, -, *, /, and ^.
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";
@diakopter
diakopter / foo.p6
Last active December 2, 2015 06:01
class TreeNode {
has Int $!item;
has TreeNode $!left;
has TreeNode $!right;
method spawn(Int \item, Int \depth) {
return ChildTreeNodes(item, depth - 1);
}
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)
@diakopter
diakopter / irc-test.p6
Last active November 23, 2015 18:17 — forked from zoffixznet/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";
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
>>> 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