Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Any(iterable).isa-any(type) method #4631

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/core.c/Any-iterable-methods.pm6
Expand Up @@ -2357,6 +2357,17 @@ Consider using a block if any of these are necessary for your mapping code."
Seq.new(Rakudo::Iterator.Rotor(self.iterator,@cycle,$partial))
}

proto method isa-any(|) {*}
multi method isa-any(Any:D: Mu $type --> Bool:D) {
my $iterator := self.iterator;
nqp::until(
nqp::eqaddr((my $pulled := $iterator.pull-one),IterationEnd)
|| nqp::istype($pulled.WHAT,$type),
nqp::null
);
nqp::hllbool(nqp::not_i(nqp::eqaddr($pulled,IterationEnd)))
}

proto method nodemap(|) is nodal {*}
multi method nodemap(Associative:D: &op) {
self.new.STORE: self.keys, self.values.nodemap(&op), :INITIALIZE
Expand Down