Skip to content

LispKit Math Util

Matthias Zenger edited this page Dec 11, 2021 · 3 revisions

Library (lispkit math util) implements mathematical utility functions.

(sgn x)     [procedure]

Implements the sign/signum function. Returns -1 if x is negative, 0 (or a signed zero, when inexact) if x is zero, and 1 if x is a positive number. sgn fails if x is not a real number.

(numbers lo hi)     [procedure]
(numbers lo hi f)
(numbers lo hi guard f)

Returns a list of numbers by iterating from integer lo to integer hi (both inclusive) and applying function f to each integer in the range for which guard returns true. The default guard always returns true. The default for f is identity.

(sum xs)     [procedure]

Returns the sum of all numbers of list xs. This procedure fails if there is an element in xs which is not a number.

(product xs)     [procedure]

Returns the product of all numbers of list xs. This procedure fails if there is an element in xs which is not a number.

(minimum xs)     [procedure]

Returns the minimum of all numbers of list xs. This procedure fails if there is an element in xs which is not a number.

(maximum xs)     [procedure]

Returns the maximum of all numbers of list xs. This procedure fails if there is an element in xs which is not a number.

(conjugate x)     [procedure]

Conjugates number x. For real numbers x, conjugate returns x, otherwise x is being returned with the opposite sign for the imaginary part.

(degrees->radians x)     [procedure]

Converts degrees into radians.

(radians->degrees x)     [procedure]

Converts radians into degrees.

(prime? n)     [procedure]

Returns #t if integer n is a prime number, #f otherwise.

Clone this wiki locally