Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add "push-all" to sequential-map "normal"
The great benefit of this should be that any Slips are short-circuited
by just doing a "push-all" on the iterator of the Slip.
  • Loading branch information
lizmat committed Jul 3, 2016
1 parent 6ed117a commit 5581b24
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/core/Any-iterable-methods.pm
Expand Up @@ -292,6 +292,44 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
$result
}

method push-all($target) {
my int $redo;
my $value;
my $result;

nqp::until(
nqp::eqaddr(
($value := $!source.pull-one),IterationEnd
),
nqp::stmts(
($redo = 1),
nqp::while(
$redo,
nqp::stmts(
($redo = 0),
nqp::handle(
nqp::if(
nqp::istype(
($result := &!block($value)),Slip
) && nqp::defined($result),
$result.iterator.push-all($target),
$target.push($result)
),
'LABELED',
$!label,
'REDO',
($redo = 1),
'LAST',
(return IterationEnd)
)
),
:nohandler
)
)
);
IterationEnd
}

method sink-all() {
my int $redo;
my int $running = 1;
Expand Down

0 comments on commit 5581b24

Please sign in to comment.