Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make flat(...) consistent with .flat.
It now also returns a Seq, which means we don't end up storing any
intermediate values - both a memory and speed improvement.
  • Loading branch information
jnthn committed Sep 14, 2015
1 parent bdcccf0 commit 831b7cb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/core/List.pm
Expand Up @@ -870,12 +870,15 @@ multi infix:<,>(|) {
result
}

# These two we'll get out of "is rw" on slurpy making List, not Array.
sub list(**@list is raw) {
@list == 1 ?? @list[0].list !! @list
}
sub flat(*@flat-list is raw) {
@flat-list

# Use **@list and then .flat it, otherwise we'll end up remembering all the
# things we flatten, which would be different semantics to .flat which gives
# back a Seq.
sub flat(**@list is raw) {
@list.flat
}

sub cache(**@list is raw) {
Expand Down

0 comments on commit 831b7cb

Please sign in to comment.