diff --git a/src/core/Array.pm b/src/core/Array.pm index 280d8a1a68b..4ff5272cc22 100644 --- a/src/core/Array.pm +++ b/src/core/Array.pm @@ -1,11 +1,4 @@ augment class Array { - our Bool multi method exists(*@indices) { - if !@indices.elems || (any(@indices) < 0 || any(@indices) > self.end) { - return False; - } - [?&] map { self[$^a] !~~ Proxy }, @indices; - } - method at_pos($pos) { Q:PIR { .local pmc self, items diff --git a/src/core/List.pm b/src/core/List.pm index 39c85a98a5c..aa33fb07397 100644 --- a/src/core/List.pm +++ b/src/core/List.pm @@ -13,6 +13,15 @@ augment class List does Positional { method Str() { self.join(' ') } + multi method exists(*@indices) { + return False unless @indices; + while @indices && @indices.shift -> $key { + return False if $key < 0 + || !pir::exists__IQi(self!fill($key+1), $key); + } + True; + } + multi method fmt($format = '%s', $separator = ' ') { self.map({ .fmt($format) }).join($separator); }