shift()

Read(2683) Label: shift,

Here’s how to use shift() function.

shift()

Description:

The function performs a shift operation. It supports a decimal without the fractional part.

Syntax:

shift(x,s)

Note:

Shift left if s<0; shift right if s>0.

Parameter:

x

The expression based on which you perform the shift operation

s

An integer

Option:

@s

When shifting right, shift a sign into the leftmost position and shif a zero to this position by default

Return value:

An integer

Example:

shift(13,2)

3

shift(decimal(3),-2)

12, which is the decimal type.

A.shift()

Description:

Get a shuffled sequence.

Syntax:

A.shift(i,s)

Note:

The function traverses members of sequence A. During the traversal, if the sequence number of the current member is greater than or equal to parameter i and, at the same time, less than or equal to [A.len()-s], return the sth member after the current one; otherwise, return the current member. A.len() is the length of sequence A. If the sum of i and s is greater than A.len(), the sequence won’t be shuffled.

Parameter:

i

The starting position, which is a positive integer; 1 is the default value

s

The offset value, which is a positive integer; 1 is the default value

Return value:

A sequence

Example:

 

A

 

1

[1,2,3,4,5,6,7,8,9,10]

 

2

=A1.shift(4,3)

3

=to(10).new(~:id,~*~:value)

 

4

=A3.shift(3,2)

Before shifting:

After shifting: