* args
Multiplication.
|
>(* 2 3)
6
|
+ args
Addition. This operator also performs string and list
concatenation.
|
>(+ 1 2 3)
6
>(+ "ab" "c" "de")
"abcde"
>(+ '(1 2) '(3 4) '(5))
(1 2 3 4 5)
|
- args
Subtraction.
|
>(- 3 2)
1
|
/ args
Division
|
>(/ 1 2)
1/2
>(/ 1.0 2)
0.5
|
expt base exponent
Exponentiation.
|
>(expt 2 3)
8
|
mod dividend divisor
|
>(mod 10 3)
1
>(mod -10 3)
2
|
rand [max]
Returns a random number between 0 and 1, or between 0 and
the specified integer (excluding the integer).
|
>(rand 10)
7
>(rand)
0.9150589966057501
|
sqrt number
Square root operation
|
>(sqrt 2)
1.4142135623730951
>(sqrt -1)
0+1i
|
trunc number
Truncates to an integer. Was 'truncate' in arc0.
|
>(trunc 1.9)
1
>(trunc -1.1)
-1
|
number n
Tests if n is a number (int or num).
|
>(number 3.14)
t
|
positive x
Tests if x is a number and is positive (>= 0). This fails on complex numbers.
|
>(positive 0)
nil
>(positive -2)
nil
>(positive "a")
nil
|
abs n
Returns the absolute value.
|
>(abs -3)
3
|
round n
Rounds n to the nearest value. Halfs are rounded to the nearest even number.
|
>(round 1/2)
0
>(round 1.5)
2
>(round 0.4)
0
>(round -1.5)
-2
|
roundup n
Rounds n to the nearest value. Halfs are rounded away from zero.
|
>(roundup 1/2)
1
>(roundup 1.5)
2
>(roundup 0.4)
0
>(roundup -1.5)
-2
|
to-nearest n quantum
Rounds down to the nearest multiple of n.
|
>(to-nearest 3.14 0.1)
3.1
>(to-nearest -5 10)
-10
|
median list
Returns the median of the list (the element at the midpoint of the list when sorted).
|
>(median '(1 5 3 2 4))
3
>(median '("dog" "cat" "bird"))
"cat"
|
avg numbers
Computes the average of a list of numbers.
|
>(avg '(1+2i 0.4))
0.7+1.0i
|
even n
Tests if n is even. Argument n must be an integer.
|
>(even 1)
nil
>(even 2)
t
|
odd n
Tests if n is odd. Argument n must be an integer.
|
>(odd 1)
t
>(odd 2)
nil
|
max [arg ...]
Returns the maximum arg. The args must be comparable with >.
|
>(max 10 -3 5)
10
>(max "cat" "dog" "bird")
"dog"
|
min [arg ...]
Returns the minimum arg. The args must be comparable with <.
|
>(min 10 -3 5)
-3
>(min "cat" "dog" "bird")
"bird"
|
multiple x base
Tests if
x is a multiple of base. |
>(multiple 10 5)
t
>(multiple 11 5)
nil
|
Copyright 2008 Ken Shirriff.