Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
better approximation of zip/cross :with
(assumes left reduction, still need to deal with baseop_reduce issues
but there's no baseop available by now, and assoc doesn't come through on op)
  • Loading branch information
TimToady committed Mar 30, 2015
1 parent 8dc34c2 commit 5665280
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core/LoL.pm
Expand Up @@ -41,6 +41,9 @@ class LoL { # declared in BOOTSTRAP
sub lol (**@l) { @l }

sub infix:<X>(|lol) {
if lol.hash && lol.hash<with> {
return METAOP_CROSS(lol.hash<with>, &METAOP_REDUCE_LEFT)(|lol.list);
}
my int $n = lol.elems - 1;
my $Inf = False;
my @l = eager for 0..$n -> $i {
Expand Down Expand Up @@ -152,11 +155,13 @@ sub infix:<X>(|lol) {
}
}

my &cross = &infix:<X>;

sub infix:<Z>(|lol) {
my $arity = lol.elems;
return if $arity == 0;
if lol.hash && lol.hash<with> {
return METAOP_ZIP(lol.hash<with>, &reduce)(|lol.list);
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 5665280

Please sign in to comment.