Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
use correct assoc for :with in cross and zip
  • Loading branch information
TimToady committed Mar 31, 2015
1 parent 437fd11 commit f96ad35
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/core/LoL.pm
Expand Up @@ -40,9 +40,18 @@ class LoL { # declared in BOOTSTRAP

sub lol (**@l) { @l }

sub find-reducer-for-op($op) {
my %prec := $op.prec;
my $reducer = %prec<prec> eq 'f='
?? 'listinfix'
!! %prec<assoc> || 'left';
::('&METAOP_REDUCE_' ~ $reducer.uc);
}

sub infix:<X>(|lol) {
if lol.hash && lol.hash<with> {
return METAOP_CROSS(lol.hash<with>, &METAOP_REDUCE_LEFT)(|lol.list);
if lol.hash {
my $op = lol.hash<with>;
return METAOP_CROSS($op, find-reducer-for-op($op))(|lol.list) if $op;
}
my int $n = lol.elems - 1;
my $Inf = False;
Expand Down Expand Up @@ -158,11 +167,12 @@ sub infix:<X>(|lol) {
my &cross = &infix:<X>;

sub infix:<Z>(|lol) {
if lol.hash {
my $op = lol.hash<with>;
return METAOP_ZIP($op, find-reducer-for-op($op))(|lol.list) if $op;
}
my $arity = lol.elems;
return if $arity == 0;
if lol.hash && lol.hash<with> {
return METAOP_ZIP(lol.hash<with>, &METAOP_REDUCE_LEFT)(|lol.list);
}
my @l = eager for ^$arity -> $i {
my \elem = lol[$i]; # can't use mapping here, mustn't flatten

Expand Down

0 comments on commit f96ad35

Please sign in to comment.