Skip to content

Instantly share code, notes, and snippets.

@masak
masak / plan.md
Created October 17, 2011 21:20
D4, deconstructed

Heal the World

Let's consider a class declaration inside a quasi block:

quasi {
    class C {}
}

We definitely don't want it to be visible before the quasi block has been applied somewhere. (And we probably want to complain if it's applied twice, since that would amount to a class redeclaration.)

@TimToady
TimToady / gist:1828667
Created February 14, 2012 18:07
now mentions native types and warnings on literal OKness smartmatch attemps
OKness type unification (DRAFT)
=======================
Current problems
================
Plethora of acceptance/rejection types/values
Match
True
False
@moritz
moritz / stability.txt
Created April 9, 2012 20:56
Perl 6 synopsis stability
1: Gas: we have some ideas what features we want, and maybe how we not want to have them
2: Liquid: we have a pretty good idea how the features should look like, but
they haven't been implemented, or only by a single compiler. Or two
implementations are available, but there are open questions or problems.
3: Slushy: at least one implementation available, and a certain degree of stability
4: Solid: at least two implementations available, been in heavy use, no major
changes expected
+ ---- stability rating
| ++-- synopsis
@masak
masak / story.md
Created May 9, 2012 21:48
The sixth trick

So, there was this magician, OK?

He made a trick, and it was kinda cool and impressive, and people said "hey, neat".

Half a year later, he had another trick. People said "that's actually pretty good". One year later, he had another trick. People went "whoa". Two years later, he had developed yet another trick. It looked kind of like the previous trick, but people were happy because they also got a book.

The fifth trick was long in the coming. People said "that's enough tricks for now. the magician should just quit while he's ahead". But the fifth trick finally arrived, after almost four years. At the end of the trick, the magician bowed and said "now you are all magicians. take this trick and do good in the world".

And the people discovered that, indeed, they were now also capable of performing magic themselves. They went "this is so awesome! I'll never need another magician again in my whole life. the fifth trick is all I ever wanted!"

@sorear
sorear / go.pl6
Created June 12, 2012 21:36
Partial Go grammar with correct semicolon insertion
grammar Go {
# this is a funny grammar because we're trying to simulate a separate lexer
# so in the main "grammar" part don't parse characters yourself, use only
# lexeme tokens.
# Normally the 'real' cursor always points after whitespace. If the
# 'logical' cursor is to point to an inserted semicolon, the 'real' cursor
# will be placed ONE CHARACTER BEFORE the next token start (and the
# location will be marked in @*ADDSEMI)
@masak
masak / joke.md
Created June 25, 2012 21:14
An old joke

There was a boy who worked in the produce section of the market. A man came in and asked to buy half a head of lettuce. The boy told him they only sold whole heads of lettuce, but the man replied he did not need a whole head, but only a half head.

The boy said he would go ask his manager about the matter.

The boy walked into the back room and said, "There's some asshole out there who wants to buy only a half a head of lettuce."

As he was finishing saying this he turned around to find the man standing right behind him, so he added, "and this gentleman wants to buy the other half."

The manager okayed the deal and the man went on his way. Later the manager called on the boy and said, "You almost got yourself in a lot of trouble earlier, but I must say I was impressed with the way you got yourself out of it. You think on your feet and we like that around here. Where are you from son?"

@tadzik
tadzik / gist:3029085
Created July 1, 2012 17:44
Typed subroutines
use Test;
plan 9;
subset TwoArgSub of Sub where {
.signature.params == 2
};
my TwoArgSub $a;
lives_ok { $a = sub ($a, $b) { } };
@masak
masak / snippet1.p6
Created August 11, 2012 13:25
Small and attractive Perl 6 snippets
my $birth-date-string = prompt "When were you born (yyyy-mm-dd)?";
my $birth-date = Date.new($birth-date-string);
my $today = Date.today;
my $age = $today.year - $birth-date.year;
# But your birthday this year may not have been yet
if $today.day-of-year < $birth-date.day-of-year {
$age--;
}
@masak
masak / restaurant.pl
Last active December 17, 2015 19:59
Constraint satisfaction problem http://xkcd.com/287/ solved in Perl 6
class Constraint {
has Real %.coefficients;
has Real $.sum = 0;
}
sub unknown($unknown) {
return Constraint.new( :coefficients{ $unknown => 1 } );
}
multi infix:<+>(Constraint $l, Constraint $r) {
@winterz
winterz / setup-travis.sh
Last active May 25, 2017 01:10
travis CI setup script
#/bin/sh -f
# things to do for travis-ci in the before_install section
if ( test "`uname -s`" = "Darwin" )
then
#cmake v2.8.12 is installed on the Mac workers now
#brew update
#brew install cmake
echo