Created
October 7, 2014 15:58
-
-
Save colomon/815c50621858c086e461 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/core/metaops.pm b/src/core/metaops.pm | |
index 1b87ef7..a92f8ec 100644 | |
--- a/src/core/metaops.pm | |
+++ b/src/core/metaops.pm | |
@@ -96,6 +96,25 @@ sub METAOP_ZIP(\op, &reduce) { | |
} | |
} | |
+sub METAOP_CONTAINER_COMPARE(\op, &reduce) { | |
+ -> |lol { | |
+ my $arity = lol.elems; | |
+ my $rop = $arity == 2 ?? op !! &reduce(op); | |
+ my @lol = eager for ^lol.elems -> $i { | |
+ my \elem = lol[$i]; # can't use mapping here, mustn't flatten | |
+ | |
+ if nqp::iscont(elem) { (elem,).list.item } | |
+ else { (elem,).flat.item } | |
+ } | |
+ loop { | |
+ my \z = @lol.map: { last unless .gimme(1); .shift } | |
+ return False if z.elems < $arity; | |
+ return False unless $rop(|z); | |
+ } | |
+ True; | |
+ } | |
+} | |
+ | |
sub METAOP_REDUCE_LEFT(\op, :$triangle) { | |
my $x := $triangle ?? | |
(sub (*@values) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment