number module covers all basic arithmetic and comparison operations for numeric values in Lion. Every function validates its arguments through Effect schemas, so passing a non-number produces a typed error rather than a runtime surprise. All nine functions take exactly two arguments.
Arithmetic
number/add
Returns the sum of two numbers.
3
number/subtract
Subtracts the second number from the first.
7
number/multiply
Returns the product of two numbers.
20
number/divide
Divides the first number by the second.
5
Division by zero follows JavaScript semantics and returns
Infinity rather than throwing. Validate your divisor with number/equals? if you need to guard against it.Comparisons
All comparison functions return a boolean.number/equals?
Returns true when both numbers are strictly equal.
true
number/lessThan
Returns true when the first number is less than the second.
true
number/greaterThan
Returns true when the first number is greater than the second.
true
number/lessThanOrEqualTo
Returns true when the first number is less than or equal to the second.
true
number/greaterThanOrEqualTo
Returns true when the first number is greater than or equal to the second.
true
Using comparisons with cond
Comparison functions are the natural fit for cond branches: