Help for this page

Select Code to Download


  1. or download this
    # reorder an array using only swap(ARRAY, X, Y),
    # given a new set of indices
    ...
      my ($a, $x, $y) = @_;
      @$a[$x,$y] = @$a[$y,$x];
    }
    
  2. or download this
      for (0 .. $#$o) {
        my $idx = $$o[$_];
    ...
        (@P[$R[$_],$idx], @R[$P[$idx],$_]) =
        (@P[$idx,$R[$_]], @R[$_,$P[$idx]]);
      }