Skip to content

Commit d692b61

Browse files
author
Ryan Connelly
committed
Made almost everything in 99-problems run in both niecza and rakudo.
All changes were minor: most were fixes to logic and a couple to Pod errors. P08-viklund and P13-viklund: I couldn't get these to run without completely altering their code, so I just left them alone.
1 parent 9aa2f7b commit d692b61

20 files changed

+51
-32
lines changed

99-problems/P01-scottp.pl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ (@l)
3131
# c. Pop like perl5
3232
# pop the last element off, which also returns it
3333
# say either way
34-
say <X Y Z>.pop;
35-
<X Y Z>.pop.say;
34+
say <X Y Z>.list.pop;
35+
<X Y Z>.list.pop.say;
3636

3737

3838
# ORIGINAL LISP SPECIFICATION
@@ -42,7 +42,7 @@ (@l)
4242
# vice versa; as a result, this example does not distinguish between a
4343
# single element and a list containing a single element.
4444

45-
=begin
45+
=begin pod
4646
4747
=head1 NAME
4848
@@ -55,5 +55,5 @@ =head1 LISP
5555
* (my-last '(a b c d))
5656
(D)
5757
58-
=end
58+
=end pod
5959

99-problems/P02-scottp.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ (@l)
3232

3333
# ORIGINAL LISP SPECIFICATION
3434

35-
=begin
35+
=begin pod
3636
3737
=head1 NAME
3838
@@ -45,5 +45,5 @@ =head1 LISP
4545
* (my-but-last '(a b c d))
4646
(C D)
4747
48-
=end
48+
=end pod
4949

99-problems/P03-scottp.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ (@l, $n)
3030

3131
# ORIGINAL LISP SPECIFICATION
3232

33-
=begin
33+
=begin pod
3434
3535
=head1 NAME
3636
@@ -44,5 +44,5 @@ =head1 LISP
4444
* (element-at '(a b c d e) 3)
4545
C
4646
47-
=end
47+
=end pod
4848

99-problems/P04-scottp.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818
# ORIGINAL LISP SPECIFICATION
1919

20-
=begin
20+
=begin pod
2121
2222
=head1 NAME
2323
2424
P04 - Find the number of elements of a list
2525
26-
=end
26+
=end pod
2727

99-problems/P05-scottp.pl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
# .reverse on the object to reverse the order
99
# .join called to present the data with a " "
1010
# say displays the result
11-
say <A B C D>.reverse.join(' ');
11+
say <A B C D>.list.reverse.join(' ');
1212

1313
# b. Perl representation
1414
# .perl serialises the data as perl representation (like Data::Dumper in perl5)
1515
# .say to display the result (print with a new line)
16-
<A B C D>.reverse.perl.say;
16+
<A B C D>.list.reverse.perl.say;
1717

18-
=begin
18+
=begin pod
1919
=head1 NAME
2020
2121
P05 - Reverse a list
2222
23-
=end
23+
=end pod
2424

99-problems/P06-scottp.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
# ORIGINAL LISP SPECIFICATION
2222

23-
=begin
23+
=begin pod
2424
2525
=head1 NAME
2626
@@ -31,5 +31,5 @@ =head1 LISP
3131
P06 (*) Find out whether a list is a palindrome.
3232
A palindrome can be read forward or backward; e.g. (x a m a x).
3333
34-
=end
34+
=end pod
3535

99-problems/P07-eric256.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
sub splat (@t) {
13-
my @return;
13+
my @return = [];
1414
for @t -> $i {
1515
if ($i.isa(Array)) {
1616
@return.push( splat($i) );

99-problems/P08-eric256.pl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ (@in)
1515
my @return;
1616
my $last;
1717
for @in -> $i {
18+
# The FIRST { } will remove the 'use of uninitialised value of type Any in
19+
# String context' warning in rakudo, but niecza hasn't implemented it as of
20+
# Aug 15 2012 so I'll leave it here, but commented out.
21+
# FIRST { $last = '' }
1822
if ($i ne $last) {
1923
@return.push($i);
2024
$last = $i;

99-problems/P09-rje.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ sub p09
3131

3232
for @in -> $elem
3333
{
34-
push @out, [] if $elem ne @out[-1][0];
35-
push @out[-1], $elem;
34+
push @out, [] if $elem ne @out[*-1][0];
35+
push @out[*-1], $elem;
3636
}
3737
return @out;
3838
}

99-problems/P09-unobe.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
sub prob09 (@in) {
1414
return gather while @in.elems {
1515
my $val = @in[0];
16-
take [gather while @in[0] ~~ $val { take shift @in }];
16+
take [gather while @in.elems and @in[0] ~~ $val { take shift @in }];
1717
}
1818
}
1919
say ~@l;

0 commit comments

Comments
 (0)