cmps()

Read(29) Label: parameter, value, compare,

Description:

Compare values of parameters.

Syntax:

cmps(xi,…;yi,…)

Compare parameter xi and parameter yi. Return 0 when xi,…and yi,…are equal, otherwise compare members of them from left to right in order; return 1 when xi is greater than yi, and return -1 when xi is less than yi.

The syntax is equivalent to cmp([xi,…], [yi,…]).

cmps(xi,…; yi,…;zi,…)

Judge whether xi falls between yi and zi and make the comparison between members of parameters from left to right. Return -1 when xi is less than yi, return 1 when is xi greater than zi, and return 0 when both cases cannot hold. The syntax is equivalent to between@b([xi,…], [yi,…]:[ zi,…]).

Note:

The function compares values of parameters. Cannot make the comparison when parameter types are different.

Parameter:

xi

A single value/expression/sequence.

yi

A single value/expression/sequence.

zi

A single value/expression/sequence.

Option:

@l

Work when parameter zi is present, and make the comparison by excluding parameter yi.

@r

Work when parameter zi is present, and make the comparison by excluding parameter zi.

Return value:

0/1/-1

Example:

 

A

 

1

=cmps(2*2;1+3)

0

2

=cmps(3,2,1;1,8,9)

1

3

=cmps("s";"a")

1

4

=cmps([3],[4,5];[3,1],[2,9])

-1

5

=cmps(abs(-9);abs(3))

1

 

 

A

 

1

=cmps(5;2;9)

0

2

=cmps(5,6;5,6;7,8)

0

3

=cmps@l(5,6;5,6;7,8)

-1

4

=cmps(7,8;4,5;7,8)

0

5

=cmps@r(7,8;4,5;7,8)

1