pad()

Read(2645) Label: pad,

Here’s how to use pad() function.

pad()

Description:

Pad a string to the specified length with another string added on the left.

Syntax:

pad(s,c,l)

Note:

The function pads string s to a new length of l by continuously adding characters of string c to the left side.

Parameter:

s

A string expression.

c

A string expression

l

A number or an expression whose result is the numeric value.

Option:

@r

Pad to the right side of a string, to a new length.

Return value:

String

Example:

 

A

 

1

=pad("Soth","Miss",10)

The return value is "MissMiSoth".

2

=pad@r("Soth","er",8)

The return value is "Sotherer".

A.pad()

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"].