Skip to content

Commit

Permalink
Move .reverse and .list of List into the setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Mar 22, 2009
1 parent 34d36f0 commit 351793a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 26 deletions.
26 changes: 0 additions & 26 deletions src/classes/List.pir
Expand Up @@ -113,17 +113,6 @@ A List in item context becomes an Array.
.tailcall self.'Array'()
.end

=item list

A List in list context returns itself.

=cut

.namespace ['List']
.sub 'list' :method
.return (self)
.end

.namespace []
.sub 'list'
.param pmc values :slurpy
Expand Down Expand Up @@ -206,21 +195,6 @@ Return the number of elements in the list.
.end


.namespace ['List']
.sub 'reverse' :method
.local pmc result, it
result = new 'List'
it = self.'iterator'()
loop:
unless it goto done
$P0 = shift it
unshift result, $P0
goto loop
done:
.return (result)
.end


=back

=head2 Private methods
Expand Down
17 changes: 17 additions & 0 deletions src/setting/List.pm
@@ -1,5 +1,14 @@
class List is also {

=begin item list
A List in list context returns itself.
=end item
method list() {
return self;
}

=begin item perl()
Returns a Perl representation of a List.
Expand All @@ -9,6 +18,14 @@ Returns a Perl representation of a List.
return '[' ~ self.map({ .perl }).join(", ") ~ ']';
}

method reverse() {
my @result;
for self.iterator() {
@result.unshift($_);
}
return @result;
}

}

# vim: ft=perl6

0 comments on commit 351793a

Please sign in to comment.