A.pad()

Read(886) Label: sequence, pad, specified length,

Description:

Add members of a sequence to another one until the latter reaches certain length.

Syntax:

A.pad(x,n)

Note:

The function adds members of sequence x sequentially and continuously to sequence A until the length of A reaches n. If n is less than A’s length, the function will return A itself.

Parameter:

A

A sequence.

x

A single value or a sequence; with a sequence, add its members sequentially to sequence A.

n

An integer.

Option:

@l

Add members before the existing members of sequence A; by default the additions will be placed at its end.

@m

If the length of sequence A is the multiple of n, do not perform the adding action. If the length of A isn’t the multiple of n, add members to A until its length is the multiple of n; the number of additions – which are members of sequence x – need to be added after the existing members can be calculated with the formula – m=n-A.len()%n.

Return value:

Sequence

Example:

 

A

 

1

[a,b,c,d,e,f]

 

2

=A1.pad(["q",2],2)

["a","b","c","d","e", "f"].

3

=A1.pad("j",9)

["a","b","c","d","e", "f","j","j","j"].

4

=A1.pad@m("j",3)

["a","b","c","d","e", "f"].

5

=A1.pad@m("j",5)

["a","b","c","d","e", "f","j","j","j","j"].

6

=A1.pad@l(["q",2],11)

["q",2, "q",2, "q","a","b","c","d","e", "f"].