Skip to content

Instantly share code, notes, and snippets.

@lizmat
Created September 21, 2015 21:09
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/b74af9a1d79a9f48bf8b to your computer and use it in GitHub Desktop.
Save lizmat/b74af9a1d79a9f48bf8b to your computer and use it in GitHub Desktop.
GLRifying xx N, causes hang in t/spec/S05-transliteration/trans.t
$ git diff
diff --git a/src/core/List.pm b/src/core/List.pm
index 5b2b372..705d108 100644
--- a/src/core/List.pm
+++ b/src/core/List.pm
@@ -934,8 +934,21 @@ multi sub infix:<xx>(Mu \x, Whatever, :$thunked!) {
GATHER({ loop { take x.() } }).lazy
}
multi sub infix:<xx>(Mu \x, Int() $n, :$thunked!) {
- my int $todo = $n;
- GATHER({ take x.() while ($todo = $todo - 1) >= 0 })
+ Seq.new(class :: does Iterator {
+ has Mu $!x;
+ has int $!todo;
+ submethod BUILD(\x, \todo) { $!x := x; $!todo = todo; self }
+ method new(\x, \todo) { nqp::create(self).BUILD(x, todo) }
+ method pull-one() {
+ if $!todo {
+ $!todo = $!todo - 1;
+ $!x.()
+ }
+ else {
+ IterationEnd
+ }
+ }
+ }.new(x, $n))
}
multi sub infix:<xx>(Mu \x, Num $n) {
infix:<xx>(x, $n == Inf ?? Whatever !! $n.Int);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment