Star Sapphire Common LISP Home

Download Star Saphire
Index

LISP: *

C: Lmultiplication

min args: 0

max args: -1

[F][CLTL 12]

SYNOPSIS:

* &rest numbers

DESCRIPTION:

This returns the product of the arguments. If there are no arguments, the result is 1, which is an identity for this operation.

 

LISP: +

C: Laddition

min args: 0

max args: -1

[F][CLTL 12]

SYNOPSIS:

+ &rest numbers

DESCRIPTION:

This returns the sum of the arguments. If there are no arguments, the result is 0, which is an identity for this operation.

LISP: -

C: Lsubtraction

min args: 0

max args: -1

[F][CLTL 12]

SYNOPSIS:

- number &rest more-numbers

DESCRIPTION:

The function -, when given one argument, returns the negative of that argument.

The function -, when given more than one argument, successively subtracts from the first argument all the others, and returns the result. For example, (- 3 4 5) => -6.

LISP: /

C: Ldivision

min args: 1

max args: -1

[F][CLTL 12]

SYNOPSIS:

/ number &rest more-numbers

DESCRIPTION:

The function /, when given more than one argument, successively divides the first argument by all the others and returns the result. With one argument, / reciprocates the argument. / will produce a ratio if the mathematical quotient of two integers is not an exact integer. For example:

(/ 12 4) => 3

(/ 13 4) => 13/4

(/ -8) => -1/8

(/ 3 4 5) => 3/20

To divide one integer by another producing an integer result, use one of the functions floor, ceiling, truncate, or round.

If any argument is a floating-point number, then the rules of floating-point contagion apply.

LISP: /=

C: Lnne

min args: 1

max args: -1

[F][CLTL 12]

SYNOPSIS:

/= number &rest more-numbers

DESCRIPTION:

see =

LISP: 1+

C: Lincrement

min args: 1

max args: 1

[F][CLTL 12]

SYNOPSIS:

1+ number

DESCRIPTION:

This function returns the sum of one and its numeric argument. The argument is not altered; use incf to do this.

(1+ x) is the same as (+ x 1).

LISP: 1-

C: Ldecrement

min args: 1

max args: 1

[F][CLTL 12]

SYNOPSIS:

1- number

DESCRIPTION:

This function returns the its numeric argument less one. The argument is not altered; use decf to do this.

(1- x) is the same as (- x 1). Note that the short name may be confusing:

(1- x) does not mean 1 - x; rather, it means x - 1.

LISP: <

C: Lnlt

min args: 1

max args: -1

[F][CLTL 12]

SYNOPSIS:

< number &rest more-numbers

DESCRIPTION:

see =

LISP: <=

C: Lnle

min args: 1

max args: -1

[F][CLTL 12]

SYNOPSIS:

<= number &rest more-numbers

DESCRIPTION:

see =

LISP: =

C: Lneq

min args: 1

max args: -1

[F][CLTL 12]

SYNOPSIS:

= number &rest more-numbers

DESCRIPTION:

The relational functions each take one or more arguments, if the sequence of arguments satisfies a certain condition:

= all the same

/= all different

< monotonically increasing

> monotonically decreasing

<= monotonically nondecreasing

>= monotonically nonincreasing

then the predicate is true, and otherwise is false. For example:

(= 3 3) is true. (/= 3 3) is false.

(= 3 5) is false. (/= 3 5) is true.

([ 3 3 3 3) is true. (/= 3 3 3 3) is false.

(= 3 3 5 3) is false. (/= 3 3 5 3) is false.

(= 3 6 5 2) is false (/= 3 6 5 2) is true.

(= 3 2 3) is false. (/= 3 2 3) is false.

(< 3 5) is true. (<= 3 5) is true.

(< 3 -5) is false. (<= 3 -5) is false.

(< 3 3) is false. (<= 3 3) is true.

(< 0 3 4 6 7) is true. (<= 0 3 4 6 7) is true.

(< 0 3 4 4 6) is false. (<= 0 3 4 4 6) is true.

(> 4 3) is true. (>= 4 3) is true.

(> 4 3 3 2 0) is false. (>= 4 3 3 2 0) is true.

(> 4 3 1 2 0) is false. (>= 4 3 1 2 0) is false.

(= 3) is true. (/= 3) is true.

(< 3) is true. (<= 3) is true.

(= 3 3.0) is true. (= 3.0s0 3.0d0) is true.

(= 0.0 -0.0) is true. (= 5/2 2.5) is true.

(> 0.0 -0.0) is false. (= 0 -0.0) is true.

With two arguments, these functions perform the usual arithmetic comparison tests. With three or more arguments, they are useful for range checks as shown in the following example:

(<= 0 x 9) ;true if x is between 0 and 9, inclusive

(< 0.0 x 1.0) ;true if x is between 0.0 and 1.0, exclusive

(< -1 j (length s)) ;true if j is a valid index for s

(<= 0 j k (= (length s) 1)) ;true if j and k are each valid

;indices for s and also j<-k

LISP: >

C: Lngt

min args: 1

max args: -1

[F][CLTL 12]

SYNOPSIS:

> number &rest more-numbers

DESCRIPTION:

see =

LISP: >=

C: Lnge

min args: 1

max args: -1

[F][CLTL 12]

SYNOPSIS:

>= number &rest more-numbers

DESCRIPTION:

see =