number

fun integer::random(Min?: number, Max?: number): integer

Returns a random integer between Min and Max (where Max \(\leq 2^{32} - 1\)). If omitted, Min defaults to 0 and Max defaults to \(2^{32} - 1\).

fun real::random(Min?: number, Max?: number): real

Returns a random real between Min and Max. If omitted, Min defaults to 0 and Max defaults to 1.

type complex < number

TBD

meth complex(String: string): complex | error

Returns the complex number in String or an error if String does not contain a valid complex number.

meth (A: complex) * (B: complex): real

complex A * B.

meth (A: complex) * (B: double): complex

Returns A * B.

meth (A: complex) * (B: integer): complex

Returns A * B.

meth (A: complex) + (B: complex): real

complex A + B.

meth (A: complex) + (B: double): complex

Returns A + B.

meth (A: complex) + (B: integer): complex

Returns A + B.

meth -(A: complex): complex

Returns -A.

meth (A: complex) - (B: complex): real

complex A - B.

meth (A: complex) - (B: double): complex

Returns A - B.

meth (A: complex) - (B: integer): complex

Returns A - B.

meth (A: complex) / (B: complex): real

complex A / B.

meth (A: complex) / (B: double): complex

Returns A / B.

meth (A: complex) / (B: integer): complex

Returns A / B.

meth (Z: complex):i: real

Returns the imaginary component of Z.

meth (Z: complex):r: real

Returns the real component of Z.

meth real(Arg₁: complex)

TBD

meth ~(A: complex): complex

Returns ~A.

meth (Buffer: string::buffer):append(Value: complex)

Appends Value to Buffer.

meth (Buffer: string::buffer):append(Value: complex, Format: string)

Appends Value to Buffer using Format as a (checked) printf format string for the real and imaginary components.

type double < real

TBD

meth (A: double) != (B: double): real

Returns B if A != B, otherwise returns nil.

meth (A: double) != (B: integer): real

Returns B if A != B, otherwise returns nil.

meth (A: double) * (B: complex): complex

Returns A * B.

meth (A: double) * (B: double): real

Returns A * B.

meth (A: double) * (B: integer): real

Returns A * B.

meth (A: double) + (B: complex): complex

Returns A + B.

meth (A: double) + (B: double): real

Returns A + B.

meth (A: double) + (B: integer): real

Returns A + B.

meth ++(Real: double): real

Returns Real + 1

meth -(A: double): real

Returns -A.

meth (A: double) - (B: complex): complex

Returns A - B.

meth (A: double) - (B: double): real

Returns A - B.

meth (A: double) - (B: integer): real

Returns A - B.

meth --(Real: double): real

Returns Real - 1

meth (A: double) / (B: complex): complex

Returns A / B.

meth (A: double) / (B: double): real

Returns A / B.

meth (A: double) / (B: integer): real

Returns A / B.

meth (A: double) < (B: double): real

Returns B if A < B, otherwise returns nil.

meth (A: double) < (B: integer): real

Returns B if A < B, otherwise returns nil.

meth (A: double) <= (B: double): real

Returns B if A <= B, otherwise returns nil.

meth (A: double) <= (B: integer): real

Returns B if A <= B, otherwise returns nil.

meth (Real₁: double) <> (Real₂: double): integer

Returns -1, 0 or 1 depending on whether Real₁ is less than, equal to or greater than Real₂.

meth (Real₁: double) <> (Int₂: integer): integer

Returns -1, 0 or 1 depending on whether Real₁ is less than, equal to or greater than Int₂.

meth (A: double) = (B: double): real

Returns B if A = B, otherwise returns nil.

meth (A: double) = (B: integer): real

Returns B if A = B, otherwise returns nil.

meth (A: double) > (B: double): real

Returns B if A > B, otherwise returns nil.

meth (A: double) > (B: integer): real

Returns B if A > B, otherwise returns nil.

meth (A: double) >= (B: double): real

Returns B if A >= B, otherwise returns nil.

meth (A: double) >= (B: integer): real

Returns B if A >= B, otherwise returns nil.

meth (A: double):max(B: double): real

Returns max(A, B).

meth (A: double):max(B: integer): real

Returns max(A, B).

meth (A: double):min(B: double): real

Returns min(A, B).

meth (A: double):min(B: integer): real

Returns min(A, B).

meth (Buffer: string::buffer):append(Value: double)

Appends Value to Buffer.

meth (Buffer: string::buffer):append(Value: double, Format: string)

Appends Value to Buffer using Format as a (checked) printf format string.

type integer < real, function

A 64-bit signed integer value.

fun (I: integer)(Arg₁, ..., Argₙ): any | nil

Returns the I-th argument or nil if there is no I-th argument. Negative values of I are counted from the last argument. In particular, 0(...) always returns nil and 1 behaves as the identity function.

2("a", "b", "c") :> "b"
-1("a", "b", "c") :> "c"
4("a", "b", "c") :> nil
0("a", "b", "c") :> nil
meth integer(Real: double): integer

Converts Real to an integer (using default rounding).

meth integer(String: string): integer | error

Returns the base 10 integer in String or an error if String does not contain a valid integer.

integer("123") :> 123
integer("ABC")
:> error("ValueError", "Error parsing integer")
meth integer(String: string, Base: integer): integer | error

Returns the base Base integer in String or an error if String does not contain a valid integer.

fun integer::random_cycle(Max: integer): list

Returns a random cyclic permutation (no sub-cycles) of 1, ..., Max.

fun integer::random_permutation(Max: integer): list

Returns a random permutation of 1, ..., Max.

meth (A: integer) != (B: double): real

Returns B if A != B, otherwise returns nil.

meth (A: integer) != (B: integer): integer

Returns B if A != B, otherwise returns nil.

meth (Int₁: integer) !| (Int₂: integer): integer

Returns Int₂ if it is not divisible by Int₁ and nil otherwise.

meth (Int₁: integer) % (Int₂: integer): integer

Returns the remainder of Int₁ divided by Int₂. Note: the result is calculated by rounding towards 0. In particular, if Int₁ is negative, the result will be negative. For a nonnegative remainder, use Int₁ mod Int₂.

meth (A: integer) * (B: complex): complex

Returns A * B.

meth (A: integer) * (B: double): real

Returns A * B.

meth (A: integer) * (B: integer): integer

Returns A * B.

meth (A: integer) + (B: complex): complex

Returns A + B.

meth (A: integer) + (B: double): real

Returns A + B.

meth (A: integer) + (B: integer): integer

Returns A + B.

meth ++(Int: integer): integer

Returns Int + 1

meth -(A: integer): integer

Returns -A.

meth (A: integer) - (B: complex): complex

Returns A - B.

meth (A: integer) - (B: double): real

Returns A - B.

meth (A: integer) - (B: integer): integer

Returns A - B.

meth --(Int: integer): integer

Returns Int - 1

meth (A: integer) / (B: complex): complex

Returns A / B.

meth (A: integer) / (B: double): real

Returns A / B.

meth (Int₁: integer) / (Int₂: integer): integer | real

Returns Int₁ / Int₂ as an integer if the division is exact, otherwise as a real.

let N := 10 / 2 :> 5
type(N) :> <<int32>>
let R := 10 / 3 :> 3.33333333333333
type(R) :> <<double>>
meth (A: integer) /(B: integer): integer

Returns the bitwise and of A and B.

meth (A: integer) < (B: double): real

Returns B if A < B, otherwise returns nil.

meth (A: integer) < (B: integer): integer

Returns B if A < B, otherwise returns nil.

meth (A: integer) << (B: integer): integer

Returns A << B.

meth (A: integer) <= (B: double): real

Returns B if A <= B, otherwise returns nil.

meth (A: integer) <= (B: integer): integer

Returns B if A <= B, otherwise returns nil.

meth (Int₁: integer) <> (Real₂: double): integer

Returns -1, 0 or 1 depending on whether Int₁ is less than, equal to or greater than Real₂.

meth (Int₁: integer) <> (Int₂: integer): integer

Returns -1, 0 or 1 depending on whether Int₁ is less than, equal to or greater than Int₂.

meth (A: integer) = (B: double): real

Returns B if A = B, otherwise returns nil.

meth (A: integer) = (B: integer): integer

Returns B if A = B, otherwise returns nil.

meth (A: integer) > (B: double): real

Returns B if A > B, otherwise returns nil.

meth (A: integer) > (B: integer): integer

Returns B if A > B, otherwise returns nil.

meth (A: integer) >< (B: integer): integer

Returns the bitwise xor of A and B.

meth (A: integer) >= (B: double): real

Returns B if A >= B, otherwise returns nil.

meth (A: integer) >= (B: integer): integer

Returns B if A >= B, otherwise returns nil.

meth (A: integer) >> (B: integer): integer

Returns A >> B.

meth (A: integer) / (B: integer): integer

Returns the bitwise or of A and B.

meth (A: integer):bsf: integer

Returns the index of the least significant 1-bit of A, or 0 if A = 0.

16:bsf :> 5
10:bsf :> 2
0:bsf :> 0
meth (A: integer):bsr: integer

Returns the index of the most significant 1-bit of A, or 0 if A = 0.

16:bsr :> 5
10:bsr :> 4
0:bsr :> 0
meth (X: integer):dec: integer

Atomic equivalent to X := old - 1.

meth (X: integer):dec(Y: integer): integer

Atomic equivalent to X := old - Y.

meth (Int₁: integer):div(Int₂: integer): integer

Returns the quotient of Int₁ divided by Int₂. The result is calculated by rounding down in all cases.

meth (X: integer):inc: integer

Atomic equivalent to X := old + 1.

meth (X: integer):inc(Y: integer): integer

Atomic equivalent to X := old + Y.

meth (A: integer):max(B: double): real

Returns max(A, B).

meth (A: integer):max(B: integer): integer

Returns max(A, B).

meth (A: integer):min(B: double): real

Returns min(A, B).

meth (A: integer):min(B: integer): integer

Returns min(A, B).

meth (Int₁: integer):mod(Int₂: integer): integer

Returns the remainder of Int₁ divided by Int₂. Note: the result is calculated by rounding down in all cases. In particular, the result is always nonnegative.

meth real(Arg₁: integer)

TBD

meth (Int₁: integer) | (Int₂: integer): integer

Returns Int₂ if it is divisible by Int₁ and nil otherwise.

meth ~(A: integer): integer

Returns ~A.

meth (Buffer: string::buffer):append(Value: integer)

Appends Value to Buffer in base 10.

meth (Buffer: string::buffer):append(Value: integer, Base: integer)

Appends Value to Buffer in base Base.

meth (Buffer: string::buffer):append(Value: integer, Format: string)

Appends Value to Buffer using Format as a (checked) printf format string.

type number

Base type for numbers.

meth (Number: number):isfinite(Arg₂: double): number | nil

Returns Number if it is finite (neither ±∞ nor NaN), otherwise returns nil.

meth (Number: number):isnan(Arg₂: double): number | nil

Returns Number if it is NaN, otherwise returns Number.

type real < complex

TBD

def real::NaN: real

Not a number.

def real::Inf: real

Positive infinity.

meth real(String: string): real | error

Returns the real number in String or an error if String does not contain a valid real number.

meth (Real₁: real) % (Real₂: real): integer

Returns the remainder of Real₁ divided by Real₂. Note: the result is calculated by rounding towards 0. In particular, if Real₁ is negative, the result will be negative. For a nonnegative remainder, use Real₁ mod Real₂.

meth complex(Arg₁: real)

TBD

meth complex(Arg₁: real, Arg₂: real)

TBD

meth (Real₁: real):div(Real₂: real): integer

Returns the quotient of Real₁ divided by Real₂. The result is calculated by rounding down in all cases.

meth (Int₁: real):mod(Int₂: real): integer

Returns the remainder of Int₁ divided by Int₂. Note: the result is calculated by rounding down in all cases. In particular, the result is always nonnegative.

meth number(String: string): integer | real | complex | error

Returns the number in String or an error if String does not contain a valid number.