[Next] [Previous] [Up] [Top] [Contents] [Index]

12 The Built-In Functions

Arithmetic Operations

When instances of <rational> and instances of <float> are combined by a numerical function, the instance of <rational> is first converted to an instance of <float> of the same format as the original instance of <float>.

Properties

odd? [Function]


Tests for the property of being an odd number.

Signature:
odd? integer Þ boolean

Arguments:
integer An instance of <integer>.

Values:
boolean An instance of <boolean>.

Description:
Returns true if its argument is an odd number.

even? [Function]


Tests for the property of being an even number.

Signature:
even? integer Þ boolean

Arguments:
integer An instance of <integer>.

Values:
boolean An instance of <boolean>.

Description:
Returns true if its argument is an even number.

zero? [Open Generic Function]


Tests for the property of being equal to zero.

Signature:
zero? object Þ boolean

Arguments:
object An instance of <object>.

Values:
boolean An instance of <boolean>.

Description:
Returns true if its argument is equal to zero.

zero? complex Þ boolean [G.F. Method]

A method is defined for the class <complex>.

positive? [Open Generic Function]


Tests for the property of being positive.

Signature:
positive? object Þ boolean

Arguments:
object An instance of <object>.

Values:
boolean An instance of <boolean>.

Description:
Returns true if its argument is positive.

positive? real Þ boolean [G.F. Method]

A method is defined for the class <real>.

negative? [Open Generic Function]


Tests for the property of being negative.

Signature:
negative? object Þ boolean

Arguments:
object An instance of <object>.

Values:
boolean An instance of <boolean>.

Description:
Returns true if its argument is negative.

negative? real Þ boolean [G.F. Method]

A method is defined for the class <real>.

integral? [Open Generic Function]


Tests for the property of being integral.

Signature:
integral? object Þ boolean

Arguments:
object An instance of <object>.

Values:
boolean An instance of <boolean>.

Description:
Returns true if its argument is an integer.

integral? object Þ false [G.F. Method]

A method is defined for the class <object> which returns #f.

integral? real Þ boolean [G.F. Method]

A method is defined for real numbers which is equivalent to real = round(real).

Arithmetic Operations

+ [Open Generic Function]


Returns the sum of its arguments.

Signature:
object1 + object2 Þ #rest objects

Arguments:
object1 An instance of <object>.

object2
An instance of <object>.

Values:
objects Instances of <object>.

Description:
Adds two objects and returns the sum.

complex1 + complex2 Þ complex [G.F. Method]

A predefined method returns the sum of two complex numbers.

* [Open Generic Function]


Returns the product of its arguments.

Signature:
object1 * object2 Þ #rest objects

Arguments:
object1 An instance of <object>.

object2
An instance of <object>.

Values:
objects Instances of <object>.

Description:
Multiplies two objects and returns the product.

complex1 * complex2 Þ complex [G.F. Method]

A predefined method returns the product of two complex numbers.

- [Open Generic Function]


Returns the difference of its arguments.

Signature:
object1 - object2 Þ #rest objects

Arguments:
object1 An instance of <object>.

object2
An instance of <object>.

Values:
objects Instances of <object>.

Description:
Subtracts object2 from object1 and returns the difference.

complex1 - complex2 Þ complex [G.F. Method]

A predefined method returns the difference of two complex numbers.

/ [Open Generic Function]


Returns the quotient of its arguments.

Signature:
object1 / object2 Þ #rest objects

Arguments:
object1 An instance of <object>.

object2
An instance of <object>.

Values:
objects Instances of <object>.

Description:
Divides object2 into object1 and returns the quotient.

complex1 / complex2 Þ complex [G.F. Method]

A predefined method returns the quotient of two complex numbers.

Division by zero signals an error.

The result of dividing two integers with / is implementation defined. Portable programs should use floor/, ceiling/, round/, or truncate/ to divide two integers.

negative [Open Generic Function]


Returns the negation of an object.

Signature:
negative object1 Þ #rest objects

Arguments:
object1 An instance of <object>.

Values:
objects Instances of <object>.

Description:
Returns the negation of its argument. The unary minus operator is equivalent to a call to the negative in the current binding environment.

negative real1 Þ real2 [G.F. Method]

A predefined method returns the additive inverse of a real number.

floor [Function]


Truncates a real number towards negative infinity.

Signature:
floor real1 Þ integer real2

Arguments:
real1 An instance of <real>.

Values:
integer An instance of <integer>.

real2
An instance of <real>.

Description:
Truncates real1 towards negative infinity. The integer part is returned as integer, the remainder is returned as real2.

ceiling [Function]


Truncates a real number towards positive infinity.

Signature:
ceiling real1 Þ integer real2

Arguments:
real1 An instance of <real>.

Values:
integer An instance of <integer>.

real2
An instance of <real>.

Description:
Truncates real1 towards positive infinity. The integer part is returned as integer, the remainder is returned as real2.

round [Function]


Rounds a real number towards the nearest mathematical integer.

Signature:
round real1 Þ integer real2

Arguments:
real1 An instance of <real>.

Values:
integer An instance of <integer>.

real2
An instance of <real>.

Description:
Rounds real1 towards towards the nearest mathematical integer. The integer part is returned as integer, the remainder is returned as real2.

truncate [Function]


Truncates a real number towards zero.

Signature:
truncate real1 Þ integer real2

Arguments:
real1 An instance of <real>.

Values:
integer An instance of <integer>.

real2
An instance of <real>.

Description:
Truncates real1 towards zero. The integer part is returned as integer, the remainder is returned as real2.

floor/ [Function]


Returns the floor of the quotient of two numbers.

Signature:
floor/ real1 real2 Þ integer real3

Arguments:
real1 An instance of <real>.

real2
An instance of <real>.

Values:
integer An instance of <integer>.

real3
An instance of <real>.

Description:
Divides real2 into real1 and truncates the result towards negative infinity. The integer part of the result is returned as integer, the remainder is returned as real3.

ceiling/ [Function]


Returns the ceiling of the quotient of two numbers.

Signature:
ceiling/ real1 real2 Þ integer real3

Arguments:
real1 An instance of <real>.

real2
An instance of <real>.

Values:
integer An instance of <integer>.

real3
An instance of <real>.

Description:
Divides real2 into real1 and truncates the result towards positive infinity. The integer part of the result is returned as integer, the remainder is returned as real3.

round/ [Function]


Rounds off the quotient of two numbers.

Signature:
round/ real1 real2 Þ integer real3

Arguments:
real1 An instance of <real>.

real2
An instance of <real>.

Values:
integer An instance of <integer>.

real3
An instance of <real>.

Description:
Divides real2 into real1 and rounds the result towards the nearest mathematical integer. The integer part of the result is returned as integer, the remainder is returned as real3.

truncate/ [Function]


Returns the truncated quotient of two numbers.

Signature:
truncate/ real1 real2 Þ integer real3

Arguments:
real1 An instance of <real>.

real2
An instance of <real>.

Values:
integer An instance of <integer>.

real3
An instance of <real>.

Description:
Divides real2 into real1 and truncates the result towards zero. The integer part of the result is returned as integer, the remainder is returned as real3.

modulo [Function]


Returns the second value of floor/.

Signature:
modulo real1 real2 Þ real3

Arguments:
real1 An instance of <real>.

real2
An instance of <real>.

Values:
real3 An instance of <real>.

Description:
Returns the second value of floor/(real1 , real2).

remainder [Function]


Returns the second value of truncate/.

Signature:
remainder real1 real2 Þ real3

Arguments:
real1 An instance of <real>.

real2
An instance of <real>.

Values:
real3 An instance of <real>.

Description:
Returns the second value of truncate/(real1 , real2).

^ [Open Generic Function]


Raises an object to a specified power.

Signature:
object1 ^ object2 Þ #rest objects

Arguments:
object1 An instance of <object>.

object2
An instance of <object>.

Values:
objects Instances of <object>.

Description:
Returns object1 raised to the power object2.

complex1 ^ complex2 Þ number [G.F. Method]

A predefined method raises a complex number to the power of another complex number and returns the result.

abs [Open Generic Function]


Returns the absolute value of its argument.

Signature:
abs object1 Þ #rest objects

Arguments:
object1 An instance of <object>.

Values:
objects Instances of <object>.

Description:
Returns the absolute value of object1.

abs complex1 Þ complex [G.F. Method]

A predefined method returns the absolute value of a complex number.

logior [Function]


Returns the bitwise inclusive or of its integer arguments.

Signature:
logior #rest integers Þ integer

Arguments:
integers Zero or more instances of <integer>.

Values:
integer An instance of <integer>..

Description:
Returns the bitwise inclusive or of the integers.

logxor [Function]


Returns the bitwise exclusive or of its integer arguments.

Signature:
logxor #rest integers Þ integer

Arguments:
integers Zero or more instances of <integer>.

Values:
integer An instance of <integer>.

Description:
Returns the bitwise exclusive or of the integers.

logand [Function]


Returns the bitwise and of its integer arguments.

Signature:
logand #rest integers Þ integer

Arguments:
integers Zero or more instances of <integer>.

Values:
integer An instance of <integer>.

Description:
Returns the bitwise and of the integers.

lognot [Function]


Returns the bitwise not of its integer argument.

Signature:
lognot integer1 Þ integer2

Arguments:
integer1 An instance of <integer>.

Values:
integer2 An instance of <integer>.

Description:
Returns the bitwise not of the integer1.

logbit? [Function]


Tests the value of a particular bit in its integer argument.

Signature:
logbit? index integer Þ boolean

Arguments:
index An instance of <integer>.

integer
An instance of <integer>.

Values:
boolean An instance of <boolean>.

Description:
Returns true if the indexth bit in integer is a one-bit; otherwise it returns false.

Negative integers are treated as if they were in two's-complement notation.

ash [Function]


Performs an arithmetic shift on its first argument.

Signature:
ash integer1 count Þ integer2

Arguments:
integer1 An instance of <integer>.

count
An instance of <integer>.

Values:
integer2 An instance of <integer>.

Description:
Performs an arithmetic shift on the binary representation of integer1.

ash shifts integer1 arithmetically left by count bit positions if count is positive, or right count bit positions if count is negative. The shifted value of the same sign as integer1 is returned.

When ash moves bits to the left, it adds zero-bits at the right. When it moves them to the right, it discards bits.

ash is defined to behave as if integer1 were represented in two's complement form, regardless of how integers are represented by the implementation.

ash(8, 1)
  Þ  16
ash(32, -1)
  Þ  16

lcm [Function]


Returns the least common multiple of two integers.

Signature:
lcm integer1 integer2 Þ integer

Arguments:
integer1 An instance of <integer>.

integer2
An instance of <integer>.

Values:
integer An instance of <integer>.

Description:
Returns the least common multiple of integer1 and integer2.

gcd [Function]


Returns the greatest common divisor of two integers.

Signature:
gcd integer1 integer2 Þ integer

Arguments:
integer1 An instance of <integer>.

integer2
An instance of <integer>.

Values:
integer An instance of <integer>.

Description:
Returns the greatest common divisor of integer1 and integer2.


Dylan Reference Manual - 17 OCT 1995
[Next] [Previous] [Up] [Top] [Contents] [Index]

Generated with Harlequin WebMaker