• esProc
Tutorial
Function Reference
Code Reference
User Reference
External Library Guide
Data File Tool Manual
DQL Tutorial
Cluster Server Manager Manual
SPL WIN Manual
• YModel
User Reference
JSON-style Parameter Guide
• ReportLite
User Reference
• Official Website

# swap()

Read（1965） Label: interval, integer sequence, swap,

Here’s how to use swap() function.

## A.swa p()

Description:

Generate a new sequence by swapping the positions of two intervals in a sequence specified by two integer sequences.

Syntax:

A.swap(p,q)

Note:

This function swaps positions between two intervals in sequence A that are respectively specified by two integer sequences that do not overlap each other.

Parameter:

 A A sequence p An integer sequence composed of positive integers, for example [1,2,3 ], i.e. to (1,3) q An integer sequence composed of positive integers that doesn’t have intersection with p, for example [4,5,6], i.e. to(4,6)

Return value:

Sequence

Example:

 A 1 [a,b,c,d,e,f,g.h.i.j.k] 2 =A1.swap(to(1,3),to(4,6)) [d,e,f,a,b,c,g.h.i.j.k]. 3 =A1.swap(to(1,4),to(4,6)) Error message appears because the two intervals in A3 overlap each other.

Note:

The two intervals to be swapped in a sequence should not overlap each other.