Skip to content

Instantly share code, notes, and snippets.

@tadzik
Created March 7, 2012 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tadzik/1992817 to your computer and use it in GitHub Desktop.
Save tadzik/1992817 to your computer and use it in GitHub Desktop.
diff --git a/src/core/Set.pm b/src/core/Set.pm
index c7e8afe..20b887e 100644
--- a/src/core/Set.pm
+++ b/src/core/Set.pm
@@ -16,7 +16,7 @@ my class Set is Iterable does Associative {
my %e;
sub register-arg($arg) {
given $arg {
- when Pair { %e{.key} = True; }
+ when Pair { if .value { %e{.key} = True; } }
when Set | KeySet { for .keys -> $key { %e{$key} = True; } }
when Associative { for .pairs -> $p { register-arg($p); } }
when Positional { for .list -> $p { register-arg($p); } }
@@ -60,7 +60,7 @@ sub set(*@args) {
Set.new(@args);
}
-my class KeySet is Iterable does Associative {
+my class KeyHash is Iterable does Associative {
has %!elems;
method keys { %!elems.keys }
@@ -82,7 +82,7 @@ my class KeySet is Iterable does Associative {
my %e;
sub register-arg($arg) {
given $arg {
- when Pair { %e{.key} = True; }
+ when Pair { if .value { %e{.key} = True; } }
when Set | KeySet { for .keys -> $key { %e{$key} = True; } }
when Associative { for .pairs -> $p { register-arg($p); } }
when Positional { for .list -> $p { register-arg($p); } }
@@ -107,3 +107,6 @@ my class KeySet is Iterable does Associative {
method pick($count = 1) { %!elems.keys.pick($count) }
method roll($count = 1) { %!elems.keys.roll($count) }
}
+
+my class KeySet is KeyHash { } # XXX Should be KeyHash of Bool
+my class KeyWeight is KeyHash { } # XXX Should be KeyHash of Rat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment