Skip to content

Instantly share code, notes, and snippets.

View ab5tract's full-sized avatar

ab5tract ab5tract

  • Amsterdam, Netherlands
View GitHub Profile
@ab5tract
ab5tract / crc-getter-extended.raku
Last active November 27, 2023 18:47
"Tikka's Zig Adventure" -- Raku Advent Research
#!/usr/bin/env raku
use v6.*;
unit sub MAIN(:$runs = 5, :$volume = 100, :$bad-packages = False);
use String::CRC32;
use NativeCall;
constant LIB = "./zig-out/lib/crc";
sub hash_crc32(Str) returns uint32 is native(LIB) { * }
@ab5tract
ab5tract / tetrix.raku
Created November 16, 2023 18:26
Tetris in 228 un-golfed lines of Raku
use Raylib::Bindings;
constant screen-width = 500;
constant screen-height = 620;
constant drop-speed = 0.333;
constant cell-size = 30;
constant num-rows = 20;
constant num-columns = 10;
===> Searching for missing dependencies: Distribution::Builder::MakeFromJSON
===> Searching for missing dependencies: System::Query
===> Searching for missing dependencies: JSON::Fast
===> Building: Raylib::Bindings:ver<0.0.7>:auth<zef:vushu>
[Raylib::Bindings] Failed to open file /usr/local/include/raylib.h: No such file or directory
[Raylib::Bindings] in sub generate-bindings at /Users/longwalker/code/raku/z.others/raylib-raku/lib/Raylib/Generator.rakumod (Raylib::Generator) line 10
[Raylib::Bindings] in sub configure at configure.raku line 15
[Raylib::Bindings] in sub MAIN at configure.raku line 43
[Raylib::Bindings] in block <unit> at configure.raku line 3
[Raylib::Bindings] Actually thrown at:
# Subtest: Block with POST phaser block
# -> {
# POST {
# $post = $_
# }();
# $result
# }
not ok 1 - deparse
# Failed test 'deparse'
# at /home/longwalker/code/raku/z.others/rakudo/t/12-rakuast/statement-phaser.rakutest line 1471
@ab5tract
ab5tract / compare-test-outputs.raku
Created August 26, 2023 11:41
Quick script to compare which tests are passing/failing between base and changes
#!/usr/bin/env raku
sub MAIN($file-a, $file-b) {
my $set-a = $file-a.IO.lines;
say "{$set-a.elems} passing tests in $file-a";
my $set-b = $file-b.IO.lines;
say "{$set-b.elems} passing tests in $file-b";
# Symmetric difference doesn't account for what is missing from where..
# we may pass tests in A that fail in B, but also tests in B that pass in B but fail in A
@ab5tract
ab5tract / gist:bb094655f1829de2906759d83e54264f
Created July 15, 2023 08:57
Artificial map element threshold in REPL
my @a = <no> xx 103; # Golfed value.. any list longer than 102 elements is affected
my $x; @a.map: { $x++ };
$x #=> 102
# note this:
my $x; @a.map: { $x++ }; $x #=> 103
@ab5tract
ab5tract / type-subset.t
Created February 14, 2023 21:50
Tests for getting RakuAST::Type::Subset working
use v6.d;
use lib <t/packages/>;
use Test;
use Test::Helpers;
plan 10;
subtest "When refinement is an expression value", {
plan 3;
@ab5tract
ab5tract / Raku-Grammar.nqp
Created February 13, 2023 13:05
Failing to parse 'enum'
token type_declarator:sym<enum> {
# <sym><.kok>
:my $*IN_DECL := 'enum';
# [
# | <longname>
# | <variable>
# | <?>
# ]
{ $*IN_DECL := '' }
# <.ws>
@ab5tract
ab5tract / Base
Last active February 10, 2023 14:31
Differences between base QAST and branch QAST -- 'subset F where * == 5; my F $f = 6'
- QAST::Block(:name(<unit-outer>) :cuid(3)) :in_stmt_mod<?> subset F where * == 5; my F $f = 6
│ - QAST::Var(local __args__ :decl(param))
│ - QAST::Stmts subset F where * == 5; my F $f = 6
│ - QAST::Op(bind)
│ - QAST::Var(lexical RakuAST :decl(var))
│ - QAST::Op(callmethod new)
│ - QAST::Var(lexical Failure)
│ - QAST::Op(callmethod new)
│ - QAST::WVal(X::Experimental)
│ - QAST::SVal+{QAST::SpecialArg}(RakuAST :named<feature>)
- QAST::Block(:name(<unit>) :cuid(1) :blocktype(declaration_static)) :IN_DECL<mainline> * && 5
│ - QAST::Stmts
│ - QAST::Stmts
│ - QAST::WVal(Nil)
│ - QAST::Stmts * && 5
│ - QAST::Var(local __args__ :decl(param))
│ - QAST::Stmts
│ - QAST::Var(lexical !RAKUAST_MARKER :decl(static))
│ [value]
│ - 1