Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@lizmat
Created September 21, 2015 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lizmat/a24f1fb4c2d3d8aa7465 to your computer and use it in GitHub Desktop.
Save lizmat/a24f1fb4c2d3d8aa7465 to your computer and use it in GitHub Desktop.
GLRifying "foo" xx *, causes several test fails
diff --git a/src/core/List.pm b/src/core/List.pm
index 5b2b372..7e7f169 100644
--- a/src/core/List.pm
+++ b/src/core/List.pm
@@ -924,6 +924,13 @@ sub flat(**@list is raw) {
sub cache(+@l) { @l }
+role XX-Whatever does Iterator {
+ has Mu $!x;
+ submethod BUILD(\x) { $!x := x; self }
+ method new(\x) { nqp::create(self).BUILD(x) }
+ method is-lazy() { True }
+}
+
proto sub infix:<xx>(|) { * }
multi sub infix:<xx>() { fail "No zero-arg meaning for infix:<xx>" }
multi sub infix:<xx>(Mu \x) { x }
@@ -931,17 +938,30 @@ multi sub infix:<xx>(Mu \x, Num $n, :$thunked!) {
infix:<xx>(x, $n == Inf ?? Whatever !! $n.Int, :$thunked);
}
multi sub infix:<xx>(Mu \x, Whatever, :$thunked!) {
- GATHER({ loop { take x.() } }).lazy
+ Seq.new(class :: does XX-Whatever { method pull-one() { $!x.() } }.new(x))
}
multi sub infix:<xx>(Mu \x, Int() $n, :$thunked!) {
}
multi sub infix:<xx>(Mu \x, Num $n) {
infix:<xx>(x, $n == Inf ?? Whatever !! $n.Int);
}
multi sub infix:<xx>(Mu \x, Whatever) {
- GATHER({ loop { take x } }).lazy
+ Seq.new(class :: does XX-Whatever { method pull-one() { $!x } }.new(x))
}
multi sub infix:<xx>(Mu \x, Int() $n) {
my int $size = $n;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment