Permalink
Browse files

Make Parcel.reverse return a Parcel rather than a List

  • Loading branch information...
1 parent b3ea82b commit 2684416fce76297ad97879a6926dcf611f077aaf @lizmat lizmat committed Oct 22, 2013
Showing with 9 additions and 0 deletions.
  1. +9 −0 src/core/Parcel.pm
View
@@ -35,6 +35,15 @@ my class Parcel does Positional { # declared in BOOTSTRAP
method list() { nqp::p6list(nqp::clone($!storage), List, Mu) }
method lol() { nqp::p6list(nqp::clone($!storage), LoL, Mu) }
+ method reverse() {
+ my Mu $reverse := nqp::list();
+ my Mu $original := nqp::clone($!storage);
+ nqp::push($reverse, nqp::pop($original)) while $original;
+ my $parcel := nqp::create(self.WHAT);
+ nqp::bindattr($parcel, Parcel, '$!storage', $reverse);
+ $parcel;
+ }
+
method rotate (Int $n is copy = 1) {
my Mu $storage := nqp::clone($!storage);
$n %= nqp::p6box_i(nqp::elems($!storage));

0 comments on commit 2684416

Please sign in to comment.