Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix infinite regress on List.invert
  • Loading branch information
TimToady committed Feb 28, 2015
1 parent f786d89 commit 6f9016e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/core/Any.pm
Expand Up @@ -82,8 +82,6 @@ my class Any { # declared in BOOTSTRAP
multi method antipairs(Any:D:) { self.list.pairs }

proto method invert(|) { * }
multi method invert(Any:U:) { ().list }
multi method invert(Any:D:) { self.list.invert }

method squish(|c) { self.list.squish(|c) }
method rotor(|c) { self.list.rotor(|c) }
Expand Down
4 changes: 4 additions & 0 deletions src/core/List.pm
Expand Up @@ -598,6 +598,10 @@ my class List does Positional { # declared in BOOTSTRAP
self.values.map: { $_ => (state $)++ }
}

multi method invert(List:D:) {
self.map: { .value »=>» .key }
}

method reduce(List: &with) {
fail('can only reduce with arity 2')
unless &with.arity <= 2 <= &with.count;
Expand Down

0 comments on commit 6f9016e

Please sign in to comment.