A.insert()

Read(925) Label: table sequence, insert, member,

Description:

Insert members into a sequence.

Syntax:

A.insert(k,X)

Insert the members of sequence X before position k in A, and return A

A.insert(k,x)

Insert member x before position k in A, and return A

Note:

The function inserts member x or members of sequence X before position k in sequence A. When parameter k is omitted, we assume the sequence A is ordered and insert member X(or x); if member X(or x) have already existed in A, the function won’t perform the insertion. Automatically update the index, if any, and check distinctness.

Parameter:

k

The position before which one or more members are inserted, when k==0, the member(s) will be appended in the end; insert backward from the end when k is less than 0

A

A sequence

X

A sequence composed of the members to be inserted

x

A member

Option:

@n

Return the inserted record or a record sequence of the inserted records

Return value:

Sequence

Example:

 

A

 

1

=["a","c","d","e","f"]

 

2

=A1.insert(0,"g")

[a,c,d,e,f,g], the member is appended in the end and A1 changes.

3

=A1.insert(2,["g","j"])

[a,g,j,c,d,e,f,g], insert the new members before the second member.

4

=demo.query("select * from STUDENTS")

 

5

=A4.insert@n(2,ID+10:ID,"Lily":NAME,"M":GENDER,15:AGE)

Return the inserted record.

6

=A1.insert(,"b")

[a,b,g,j,c,d,e,f,g]; assume A1 is ordered and insert a new member b.

7

=A1.insert(,"a")

[a,b,g,j,c,d,e,f,g]; member a exists in A1, so the same member won’t be inserted.

8

=A1.insert(-2,"h")

As k<0, insert backwards from the end and return [a,b,g,j,c,d,e,h,f,g].

Related function:

A.delete()

A.modify()

T.insert()