Skip to content

Commit 596ec1c

Browse files
committed
the forest-fire benchmarks now work properly post-glr as well
1 parent 56b7bbf commit 596ec1c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

perl6/rc-forest-fire

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ class Forest {
2121
}
2222

2323
method !init-grid {
24-
@!grid = [ (Bool.pick ?? Tree !! Empty) xx $!width ] xx $!height;
24+
@!grid = [ flat (Bool.pick ?? Tree !! Empty) xx $!width ] xx $!height;
2525
}
2626

2727
method !init-neighbors {
2828
@!neighbors = [ [] xx $!width ] xx $!height; # XXX rakudo doesn't autoviv yet
29-
for ^$!height X ^$!width -> $i, $j {
29+
for flat(^$!height X ^$!width) -> $i, $j {
3030
my $k = 0;
3131
for
3232
[-1,-1],[+0,-1],[+1,-1],
@@ -42,7 +42,7 @@ class Forest {
4242
method step {
4343
my @new;
4444
@new = [] xx $!height; # XXX rakudo doesn't autoviv yet
45-
for ^$!height X ^$!width -> $i, $j {
45+
for flat (^$!height X ^$!width) -> $i, $j {
4646
given @!grid[$i][$j] {
4747
when Empty { @new[$i][$j] = rand < $!p ?? Tree !! Empty }
4848
when Tree { @new[$i][$j] =
@@ -51,7 +51,7 @@ class Forest {
5151
when Burning { @new[$i][$j] = Empty }
5252
}
5353
}
54-
for ^$!height X ^$!width -> $i, $j {
54+
for flat(^$!height X ^$!width) -> $i, $j {
5555
@!grid[$i][$j] = @new[$i][$j];
5656
}
5757
}

perl6/rc-forest-fire-stringify

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ sub MAIN($w, $h, $steps) {
44
my $CLEAR = "\e[0m";
55

66
enum Cell-State <Empty Tree Burning>;
7-
my @show = (' ', $GREEN ~ '木' ~ $CLEAR, $RED ~ '火' ~ $CLEAR);
8-
my @grid := [ (Empty, Tree, Burning) xx $w ] xx $h;
7+
my @show = ' ', $GREEN ~ '木' ~ $CLEAR, $RED ~ '火' ~ $CLEAR;
8+
my @grid = [ flat (Empty, Tree, Burning) xx $w ] xx $h;
99

1010
sub stringify(@grid) {
1111
join '', gather for ^@grid -> $i {
@@ -15,7 +15,7 @@ sub MAIN($w, $h, $steps) {
1515

1616
my $chars = 0;
1717
for ^$steps {
18-
my $grid := stringify(@grid);
18+
my $grid = stringify(@grid);
1919
$chars += $grid.chars;
2020
}
2121
say $chars;

0 commit comments

Comments
 (0)