This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl6 | |
use v6; | |
# call with current continuation | |
sub infix:<⇐> (&cont, &expr) { | |
my @rest = expr &cont; | |
return @rest[ 0 ] if @rest[ 1 ]; | |
return cont @rest[ 0 ]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
// tipos | |
typedef struct node { | |
int here; | |
struct node *next; | |
} Node; | |
typedef Node * Linked; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $ perl6 --target=mbc --output=./hello.mbc -e "say 'hello'" | |
# $ moar --dump hello.mbc > hello.dump | |
MoarVM dump of binary compilation unit: | |
SC_0 : 61C9069EAD2FEF4AF84D9D502EA124CAC63EB166 | |
Callsite_0 : | |
num_pos: 0 | |
arg_count: 0 | |
Callsite_1 : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use warnings; | |
sub try (&;@;) { | |
my ($try, @tests, $finally) = @_; | |
# remove o bloco <finally> se ele veio junto | |
$finally = pop (@tests) -> { 'finally' } if ref ($tests[ -1 ]) eq "HASH"; | |
push @tests, -1; # marcador de nenhum erro capturado | |
eval { &$try }; | |
if ($@) { # houve um erro? | |
local $e = $@; # erro de escopo local (como uma variável de closure) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
### gather / take ### | |
gather { | |
@xs -> for { | $x | ($x + 1) -> take } | |
} -> eval -> say; | |
# or | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- scheduler / task test -- | |
-- object, the base prototype -- | |
local object = { } | |
-- bless / bind for lookup -- | |
-- :: Ref <$> -> Pair % -> Obj % | |
function object: with (O) | |
return setmetatable (O, { __index = self }) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v5.12; | |
use utf8; | |
use strict; | |
use warnings; | |
# to declare short arrow functions | |
sub Ω { | |
my $in = shift; | |
return sub { | |
my $out = shift; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dumping 'main' symbol table. | |
Exporter:: => *main::Exporter:: | |
*main::Exporter:: => | |
" => *main::" | |
*main::" => | |
utf8:: => *main::utf8:: | |
*main::utf8:: => | |
=> *main:: | |
*main:: => | |
DynaLoader:: => *main::DynaLoader:: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setmetatable => function: 0x8060770 | |
string => table: 0x9575d58 | |
require => function: 0x9576740 | |
coroutine => table: 0x95767a0 | |
arg => table: 0x9578970 | |
os => table: 0x9576930 | |
tostring => function: 0x805fbf0 | |
xpcall => function: 0x8060600 | |
rawset => function: 0x805ff60 | |
pairs => function: 0x8060910 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/lua | |
-- Perl6 example -- | |
--[[ | |
my @xs := gather { | |
my $x = 0; | |
my $y = 1; | |
while True { | |
take $x; |