A.range()

Read(496)

Description:

Divide a sequence into a specified number of equal segments according to its length and returns the kth segment.

Syntax:

A.range(k:n)

Note:

The function divides sequence A into n equal segments according to its length and retrieves the kth segment to return. It returns all segments when parameter k is absent. The colon (:) after parameter k cannot be omitted when k is absent.

Parameter:

A

A numeric sequence

k

An integer, which is the sequence number of a specified segment

n

An integer representing the total number of segments

Return value:

A sequence

Example:

[1,5,2,6,8,7].range (2:3)

Return sequence [2,6].

to(8).range (1:3)

Return sequence [1,2,3].

to(8).range (3:3)

Return sequence [7,8].

to(8).range (:3)

Return sequence [[1,2,3],[4,5,6],[7,8]].