Skip to content

Commit

Permalink
Better way to create the Listy return value of deepmap
Browse files Browse the repository at this point in the history
Thanks to jnthn++ for pointing this out.
  • Loading branch information
niner committed Aug 24, 2015
1 parent 65a02f4 commit ce93835
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/metaops.pm
Expand Up @@ -556,8 +556,10 @@ multi sub deepmap(\op, \obj) {
}.new(op, iterable.iterator);

my $type = nqp::istype(obj, List) ?? obj.WHAT !! List; # keep subtypes of List
my \retval = $type.from-iterator(result);
retval.is-lazy(); # fully reifies as a side-effect
my \buffer := IterationBuffer.new;
result.push-all(buffer);
my \retval = $type.new;
nqp::bindattr(retval, List, '$!reified', buffer);
nqp::iscont(obj) ?? retval.item !! retval;
}

Expand Down

0 comments on commit ce93835

Please sign in to comment.