Created
June 15, 2010 18:13
-
-
Save uasi/439458 to your computer and use it in GitHub Desktop.
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 v6; | |
role Keyed[*@keys] is Associative { | |
my %index; | |
submethod BUILD() { | |
for @keys.kv -> $i, $v { | |
%index{$v} = $i; | |
} | |
} | |
multi method postcircumfix:<{ }>() { | |
self; | |
} | |
multi method postcircumfix:<{ }>(*@keys) { | |
my @result; | |
for @keys -> $key { | |
@result.push: self[%index{$key}]; | |
} | |
@result; | |
} | |
} | |
my $a = [32, 64] but Keyed[<first second>]; | |
$a<second>.say; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment