x-lang

← Index

x/core/arithmetic

Variadic +, -, *, /, % folded over the binary C primitives.

+

Variadic addition. Returns the sum of all arguments.

Parameters:

Returns: NUMBER — Sum of all arguments, or 0 with no arguments

Examples:

(+ 1 2 3) => 6
(+) => 0

*

Variadic multiplication. Returns the product of all arguments.

Parameters:

Returns: NUMBER — Product of all arguments, or 1 with no arguments

Examples:

(* 2 3 4) => 24
(*) => 1

/

Variadic integer division. Folds left.

Parameters:

Returns: NUMBER — Quotient from left fold

Examples:

(/ 100 5 2) => 10

-

Variadic subtraction. With one argument, negates. With multiple, folds left.

Parameters:

Returns: NUMBER — Difference, or negation with one argument

Examples:

(- 10 3 2) => 5
(- 5) => -5

&

Bitwise AND.

Parameters:

Returns: INT — Bitwise AND

|

Bitwise OR.

Parameters:

Returns: INT — Bitwise OR

^

Bitwise XOR.

Parameters:

Returns: INT — Bitwise XOR

<<

Left shift.

Parameters:

Returns: INT — Shifted value

>>

Arithmetic right shift.

Parameters:

Returns: INT — Shifted value

<

Test numeric less-than.

Parameters:

Returns: BOOL — t if a < b

~

Bitwise NOT.

Parameters:

Returns: INT — Bitwise complement