- 
                Notifications
    
You must be signed in to change notification settings  - Fork 5
 
swapRanges
        Subhajit Sahu edited this page May 3, 2023 
        ·
        1 revision
      
    Exchange two ranges of values.
Alternatives: swapRanges, swapRanges$.
Similar: swap, swapRanges.
function swapRanges(x, i, I, j, J)
// x: an array
// i: begin index of first range
// I: end index of first range (exclusive)
// j: begin index of second range
// J: end index of second range (exclusive)const xarray = require('extra-array');
// Example for swapRanges
var x = [1, 2, 3, 4, 5];
xarray.swapRanges(x, 1, 3, 3, 5);
// → [ 1, 4, 5, 2, 3 ]