|
313 | 313 | name => 'reduce_range',
|
314 | 314 | tags => [qw( reduce )],
|
315 | 315 | scale => 1 << 10,
|
316 |
| - perl5 => 'use List::Util "reduce"; reduce { $a + $b } 1 .. SCALE', |
317 |
| - perl6 => '[+] 1 .. SCALE', |
| 316 | + expected => sub { (($_[0] + 1) * $_[0] / 2) . "\n" }, |
| 317 | + perl5 => 'use List::Util "reduce"; say reduce { $a + $b } 1 .. SCALE;', |
| 318 | + perl6 => 'say [+] 1 .. SCALE;', |
318 | 319 | nqp => undef,
|
319 | 320 | },
|
320 | 321 | {
|
321 | 322 | name => 'reduce_int_comb_range',
|
322 | 323 | tags => [qw( reduce )],
|
323 | 324 | scale => 1 << 7,
|
324 |
| - perl5 => 'use List::Util "reduce"; reduce { $a + $b } map { 0+$_ } map { split "" } 1 .. SCALE', |
325 |
| - perl6 => '[+] (1 .. SCALE).comb>>.Int', |
| 325 | + perl5 => 'use List::Util "reduce"; say reduce { $a + $b } map { 0+$_ } map { split "" } 1 .. SCALE; ', |
| 326 | + perl6 => 'say [+] (1 .. SCALE).comb>>.Int;', |
326 | 327 | nqp => undef,
|
327 | 328 | },
|
328 | 329 | {
|
329 | 330 | name => 'any_equals',
|
330 | 331 | tags => [qw( junctions forest-fire )],
|
331 | 332 | scale => 1 << 7,
|
| 333 | + expected => sub { $_[0] ? "1 0\n" : "0 0\n" }, |
332 | 334 | perl5 => 'my $match = grep { 1 == $_ } 1 .. SCALE; my $fail = grep { 0 == $_ } 1 .. SCALE; say "$match $fail"',
|
333 | 335 | perl6 => 'my $match = 1 == any(1 .. SCALE); my $fail = 0 == any(1 .. SCALE); say "{+?$match} {+?$fail}"',
|
334 | 336 | nqp => undef,
|
|
338 | 340 | tags => [qw( for string )],
|
339 | 341 | scale => 1 << 7,
|
340 | 342 | work => sub { $_[0] * $_[0] },
|
341 |
| - perl5 => 'my $s = " " x SCALE . "x" x SCALE . " " x SCALE; my ($result) = $s =~ /^\s*(.*?)\s*$/s for 1 .. SCALE', |
342 |
| - perl6 => 'my $s = " " x SCALE ~ "x" x SCALE ~ " " x SCALE; $s.trim for 1 .. SCALE', |
| 343 | + expected => sub { $_[0] . "\n" }, |
| 344 | + perl5 => 'my $s = " " x SCALE . "x" x SCALE . " " x SCALE; my $result = ""; ($result) = $s =~ /^\s*(.*?)\s*$/s for 1 .. SCALE; say length($result);', |
| 345 | + perl6 => 'my $s = " " x SCALE ~ "x" x SCALE ~ " " x SCALE; my $result = ""; $result = $s.trim for 1 .. SCALE; say $result.chars;', |
343 | 346 | nqp => undef,
|
344 | 347 | },
|
345 | 348 | {
|
|
0 commit comments