This file contains hidden or 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
| class Set is Iterable does Associative; | |
| has Bool %!elems[Any] handles <keys values elems exists Bool Numeric hash>; | |
| constant term:<∅> = set(); | |
| # Immutable | |
| method !STORE(\args) { | |
| die 'Sets are immutable, but you tried to modify one' | |
| } |
This file contains hidden or 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
| class Set does Associative; | |
| has Bool %!elems; | |
| method keys { %!elems.keys } | |
| method values { %!elems.values } | |
| method elems returns Int { %!elems.elems } | |
| method exists returns Bool { %!elems.exists } | |
| method Bool { %!elems.Bool } | |
| method Numeric { %!elems.Numeric } |
This file contains hidden or 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
| OKness type unification (DRAFT) | |
| ======================= | |
| Current problems | |
| ================ | |
| Plethora of acceptance/rejection types/values | |
| Match | |
| True | |
| False |
This file contains hidden or 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
| sub logic { first {! try .()}, @_ } | |
| for 1,2,3 X 1,2,3 -> $x, $y { | |
| logic { $x > 2 }, | |
| { $x + $y == 5 }, | |
| { $y < 3 }, | |
| { say "$x + $y == 5"; Nil } | |
| } |
This file contains hidden or 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
| sub amb($var,*@a) { | |
| "[{ | |
| @a.pick(*).map: {"||\{ $var = $_ }"} | |
| }]"; | |
| } | |
| '' ~~ m/ | |
| :my ($x, $y); | |
| <{ amb '$x', 1, 2, 3 }> | |
| <?{ $x > 2 }> |
This file contains hidden or 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
| sub amb($var,*@a) { | |
| "[{ | |
| @a.pick(*).map: {"||\{ $var = '$_' }"} | |
| }]"; | |
| } | |
| '' ~~ m/ | |
| :my ($a,$b,$c,$d); | |
| <{ amb '$a', <the that a> }> | |
| <{ amb '$b', <frog elephant thing> }> |
This file contains hidden or 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
| my $height = 5; | |
| my $width = 5; | |
| my @grid = [ Bool.pick xx $width ] xx $height; | |
| my @neigh = [ ] xx $height; | |
| for ^$height X ^$width -> $i, $j { | |
| @neigh[$i][$j] = gather take @grid[$i + .[0]][$j + .[1]] | |
| if 0 <= $i + .[0] < $height and 0 <= $j + .[1] < $width | |
| for [-1,-1],[+0,-1],[+1,-1], | |
| [-1,+0],( ),[+1,+0], | |
| [-1,+1],[+0,+1],[+1,+1]; |
This file contains hidden or 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 Test; | |
| { | |
| my @grid = [ Bool.pick xx 5 ] xx 5; | |
| my @neigh = [ ] xx 5; | |
| for ^5 X ^5 -> $i, $j { | |
| @neigh[$i][$j] = gather take-rw @grid[$i + .[0]][$j + .[1]] | |
| if 0 <= $i + .[0] < 5 and 0 <= $j + .[1] < 5 | |
| for [-1,-1],[+0,-1],[+1,-1], | |
| [-1,+0],( ),[+1,+0], |
This file contains hidden or 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
| edo:~/perl6/niecza 1031> gp | |
| remote: Counting objects: 15, done. | |
| remote: Compressing objects: 100% (9/9), done. | |
| remote: Total 12 (delta 6), reused 9 (delta 3) | |
| Unpacking objects: 100% (12/12), done. | |
| From github.com:sorear/niecza | |
| 6ef6b2c..d41bc4d master -> origin/master | |
| From github.com:sorear/niecza | |
| * [new tag] v17 -> v17 | |
| First, rewinding head to replay your work on top of it... |
This file contains hidden or 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/perl | |
| binmode STDIN, ":utf8"; | |
| binmode STDOUT, ":utf8"; | |
| binmode STDERR, ":utf8"; | |
| eval { binmode STD, ":utf8" }; | |
| use Encode; | |
| for (@ARGV) { Encode::_utf8_on($_) } | |
| $pat = "@ARGV"; |