PtcRunner.Lisp.Runtime.Math (PtcRunner v0.9.0)

Copy Markdown View Source

Arithmetic operations for PTC-Lisp runtime.

Provides basic math operations: addition, subtraction, multiplication, division, and utility functions like floor, ceil, round, etc.

Summary

Functions

abs(x)

add(args)

add(x, y)

ceil(x)

compare(x, y)

dec(x)

divide(x, y)

double(x)

eq(x, y)

float(x)

floor(x)

gt(x, y)

gte(x, y)

inc(x)

int(x)

lt(x, y)

lte(x, y)

max(x, y)

min(x, y)

mod(x, y)

Modulus with floored division (toward negative infinity).

The result has the same sign as the divisor (y). Matches Clojure's mod function.

multiply(args)

multiply(x, y)

not_eq(x, y)

pow(x, y)

quot(x, y)

Integer division (quotient), truncating toward zero.

Matches Clojure's quot function.

Examples

iex> PtcRunner.Lisp.Runtime.Math.quot(7, 2)
3

iex> PtcRunner.Lisp.Runtime.Math.quot(-7, 2)
-3

iex> PtcRunner.Lisp.Runtime.Math.quot(7.5, 2)
3

remainder(x, y)

Remainder with truncated division (toward zero).

The result has the same sign as the dividend (x). Matches Clojure's rem function.

round(x)

sqrt(x)

subtract(list)

subtract(x, y)

trunc(x)