Created
April 17, 2015 14:45
-
-
Save Tux/587e5914afda17e1b1ee to your computer and use it in GitHub Desktop.
This hangs
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
use v6; | |
class RangeSet { | |
has Pair @.p; | |
method add (Int $from, Any $to) { | |
@.p.push: $from => $to.Num; | |
} | |
method to_list () { | |
gather { | |
my Int $max = -1; | |
for sort @.p -> $r { | |
my $from = ($r.key, $max + 1).max.Int; | |
($from, $r.value).perl.say; | |
take $from .. $r.value; | |
$r.value == Inf and last; | |
$max = ($max, $r.value).max.Int; | |
} | |
} | |
} | |
} | |
my RangeSet $rs .= new; | |
$rs.add(0,1); | |
$rs.add(3,3); | |
$rs.add(5,Inf); | |
my Int @c = $rs.to_list; | |
#@crange.perl.say; | |
for 1..9 -> $t { | |
my @x = (10 * $t + 1) .. (10 * $t + 9); | |
my @z = @c ?? (@x[@c]:v) !! @x; | |
@z.perl.say; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment