Created
September 21, 2015 21:09
-
-
Save lizmat/b74af9a1d79a9f48bf8b to your computer and use it in GitHub Desktop.
GLRifying xx N, causes hang in t/spec/S05-transliteration/trans.t
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
$ 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