Skip to content

Instantly share code, notes, and snippets.

View lizmat's full-sized avatar
💭
Functioning within parameters

Elizabeth Mattijsen lizmat

💭
Functioning within parameters
View GitHub Profile
@lizmat
lizmat / gist:1af8dee8fc84a75b54e19e91e2a7d76d
Created October 30, 2018 21:18
Moose not installing on MacOS
Configuring E/ET/ETHER/Moose-2.2011.tar.gz with Makefile.PL
In file included from HASCOMPILERElf4/TESTbL5Q.c:3:
In file included from /usr/local/lib/perl5/5.20.0/darwin-2level/CORE/perl.h:5152:
/usr/local/lib/perl5/5.20.0/darwin-2level/CORE/inline.h:311:9: warning: nonnull
parameter 'pv' will evaluate to 'true' on first encounter
[-Wpointer-bool-conversion]
if (pv && len > 1) {
^~ ~~
/usr/local/lib/perl5/5.20.0/darwin-2level/CORE/proto.h:1791:4: note: declared
'nonnull' here
diff --git a/src/Perl6/Actions.nqp b/src/Perl6/Actions.nqp
index 44f8b80..b080f99 100644
--- a/src/Perl6/Actions.nqp
+++ b/src/Perl6/Actions.nqp
@@ -3581,6 +3581,22 @@ class Perl6::Actions is HLL::Actions does STDActions {
elsif $<type_declarator> { make $<type_declarator>.ast }
elsif $<variable_declarator> {
my $past := $<variable_declarator>.ast;
+
+ # got a 'my $*FOO', need to convert back to just a Var
@lizmat
lizmat / gist:4594bf4ae699b1464aa78ad49bb37220
Created October 3, 2018 08:54
Fastest Perl 6 object creation bench:
class Point {
has int $.x;
has int $.y;
method !SET($!x,$!y) { self }
method new(:$x is raw, :$y is raw) { self.CREATE!SET($x,$y) }
}
my $total = 0;
for ^1_000_000 -> int $_ {
my $p := Point.new(x => 2, y => 3);
$total += $p.x + $p.y;
@lizmat
lizmat / gist:0454f034b9336673cea4fb31927ca164
Created September 19, 2018 21:39
A faster JSON parser, with limited capabilities
my $meta = "META6.json".IO.slurp;
my $old = Rakudo::Internals::JSON.new.from-json($meta);
use Test;
use MONKEY;
augment class Rakudo::Internals::JSON {
@lizmat
lizmat / gist:1cc5df073b8e6f1e7de84d05edecf460
Created September 4, 2018 12:13
Problem building rakudo after bumping NQP to 2018.08-24-gec437ae
$ make install; ls -l CORE.setting.moarvm >> moarvm.sizes
/usr/local/bin/perl tools/build/check-nqp-version.pl /Users/liz/Github/rakudo.moar/install/bin/nqp-m
clang -c -fno-omit-frame-pointer -fno-optimize-sibling-calls -O3 -DNDEBUG -Wno-logical-op-parentheses -D_DARWIN_USE_64_BIT_INODE=1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -O3 -DNDEBUG -Wno-logical-op-parentheses -I/Users/liz/Github/rakudo.moar/install/include/libatomic_ops \
-I/Users/liz/Github/rakudo.moar/install/include/dyncall -I/Users/liz/Github/rakudo.moar/install/include/moar \
-I/Users/liz/Github/rakudo.moar/install/include/sha1 -I/Users/liz/Github/rakudo.moar/install/include/tinymt -I/Users/liz/Github/rakudo.moar/install/include/libtommath \
-I/Users/liz/Github/rakudo.moar/install/include/libuv -I/Users/liz/Github/rakudo.moar/install/include -I3rdparty/libuv/include -I3rdparty/libuv/src -I3rdparty/libatomicops/src -I3rdparty/libtommath -I3rdparty/dyncall/dynload -I3rdparty/dyncall/dyncall -I3rdparty/dyncall/dyncal
@lizmat
lizmat / gist:8fff372998ed43d8d33ec38165bed290
Last active August 3, 2018 14:43
LDWL solution with bonus, runs in about 8 seconds
unit sub MAIN($show-from is copy = *, $filename = "-");
# Get the words in a hash and an array from longest -> shortest
my @words;
my %words = $filename.IO.lines.map: { @words[.chars].push($_); $_ => True }
@words = @words.reverse.map: { |$_ if $_ } # flatten them out
my $lock = Lock.new; # to serialize pushes to @ldwl and deletes from %words
my @ldwl;
# Find the sum of all the primes below two million.
use v6;
my int $max = 2_000_000;
# find all primes up to $max using The Sieve of Erathostenes
my int @a = 0..$max;
@a[1] = 0; # don't include 1
for (2 .. ($max div 2)) -> int $i {
#!/usr/bin/perl
=begin metadata
Name: primes
Description: generate primes
Author: Jonathan Feinberg, jdf@pobox.com
Author: Benjamin Tilly, ben.tilly@alumni.dartmouth.org
License: perl
@lizmat
lizmat / gist:0f8272c91cdbf37f688cf2e08231c286
Created July 3, 2018 01:36
Creating a Seq from a List of Seqs
sub ListOfSeqsToSeq(**@seqs) {
Seq.new( class :: does Iterator {
has @.seqs;
has $!iterator;
method TWEAK() { $!iterator = @!seqs.shift.iterator if @!seqs }
method pull-one() is raw {
if $!iterator {
my $pulled := $!iterator.pull-one;
if $pulled =:= IterationEnd {
if @!seqs {
@lizmat
lizmat / gist:61cd573e2a0c5e9b01949e379a9fd7af
Last active April 29, 2018 19:27
updated localtime question
use NativeCall;
my class TimeStruct is repr<CStruct> {
has int32 $.tm_sec;
has int32 $.tm_min;
has int32 $.tm_hour;
has int32 $.tm_mday;
has int32 $.tm_mon;
has int32 $.tm_year;
has int32 $.tm_wday;
has int32 $.tm_yday;