Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement invert/antipairs
  • Loading branch information
perlpilot committed Aug 20, 2015
1 parent 5679420 commit 7d238fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/core/EnumMap.pm
Expand Up @@ -149,12 +149,11 @@ my class EnumMap does Iterable does Associative { # declared in BOOTSTRAP
}
}.new(self))
}
# XXX GLR implement these iterators
multi method antipairs(EnumMap:D:) {
nqp::die('Hash antipairs iterator NYI in GLR')
self.map: { .value => .key }
}
multi method invert(EnumMap:D:) {
nqp::die('Hash invert iterator NYI in GLR')
self.map: { (.value »=>» .key).list.Slip }
}

multi method AT-KEY(EnumMap:D: \key) is rw {
Expand Down
6 changes: 2 additions & 4 deletions src/core/Hash.pm
Expand Up @@ -452,12 +452,10 @@ my class Hash { # declared in BOOTSTRAP
}.new(self, $?CLASS, nqp::getattr(self, EnumMap, '$!storage')))
}
method antipairs(EnumMap:) {
return ().list unless self.DEFINITE && nqp::defined($!keys);
nqp::die('Typed hash antipairs iterator NYI in GLR')
self.map: { .value => .key }
}
method invert(EnumMap:) {
return ().list unless self.DEFINITE && nqp::defined($!keys);
nqp::die('Typed hash invert iterator NYI in GLR')
self.map: { .value »=>» .key }
}
multi method perl(::?CLASS:D \SELF:) {
my $TKey-perl := TKey.perl;
Expand Down

0 comments on commit 7d238fe

Please sign in to comment.