Revision 27073

Date:
2009/06/12 23:47:29
Author:
lwall
Revision Log:
[Containers] define .rotate more like a PDL slice, rely on other ops for exact semantics
Files:

Legend:

 
Added
 
Removed
 
Modified
  • docs/Perl6/Spec/S32-setting-library/Containers.pod

     
    269 269
    270 270 Note that strings are now reversed with C<flip>.
    271 271
    272 =item rotate
    273
    274 our List multi method rotate ( @values is copy: Int $n = 1) is export
    275
    276 Produces a new list with the same elements as the old list,
    277 rotated by the specified amount. See Array::rotate for more
    278 info.
    279
    272 280 =item sort
    273 281
    274 282 our Array multi method sort( @values: *&by )
     
    482 490
    483 491 =item rotate
    484 492
    485 our Array multi method rotate ( @array: Int $n = 1) is export
    493 our Array multi method rotate ( @array is copy: Int $n = 1, Int *@n) is export
    486 494
    487 Rotates the array and returns it. A positive rotation of 1
    488 is defined as:
    495 Produces a new array with the same elements as the old array,
    496 rotated by the specified amount. A positive rotation of 1 is defined as:
    489 497
    490 498 @array.push(@array.shift);
    491 499
     
    498 506
    499 507 @array.rotate(sign($n)) for ^abs($n)
    500 508
    501 The modified array is returned.
    509 The new array to be returned contains nothing but aliases for
    510 the old array's elements; however, you can use this to get
    511 any of three different semantic behaviors:
    502 512
    513 @a.=rotate # @a is rotated in place
    514 @b = @a.rotate # @b contains copied elements of rotated @a
    515 @b := @a.rotate # @b contains aliased elements of rotated @a
    516
    517 If additional rotations are specified via the slurpy, they are
    518 applied to subdimensions of multidimensional arrays. (To perform
    519 a flat rotation on a shaped array requires flattening to a list
    520 and rotating that instead.)
    521
    503 522 =item shift
    504 523
    505 524 our Scalar multi method shift ( @array: ) is export