Most standard math functions are included. See Steve May's Math documentation for complete lists.
Math functions can be evaluated by providing a math function with several arguments, as is shown below.
ox --> 7 7 ox --> -3.14 -3.14Math expressions require a function, followed by a list of arguments, contained within parentheses:
ox --> (+ 1 2) 3 ox --> (cos 0) 1 ox --> (abs -5) 5 ox --> (sqrt 9) 3Since all expressions return a value when evaluated, they can be arbitrarily embedded:
ox --> (+ (- 5 3) 1) 3 ox --> (+ (- 5 3) (/ 4 2)) 4 ox --> (sin (cos (tan 0))) 0.841471A few useful math functions to generate random numbers are also available.
'Rand' generates numbers between zero and one. It is "seeded" using 'srand'. The same seed value will always generate the same series of random numbers.
ox --> (srand 56789) () ox --> (rand) 0.830953873615225 ox --> (rand) 0.739195051947234There are also one, two, and three dimensional noise generators. Notice all the inputs are non-integer. "Noise" returns zero at integer values. Noise has is periodic of 256.
ox --> (noise 1) 0.0 ox --> (noise .5) 0.125609934329987 ox --> (noise 37.2 22.8) 0.107241749763489 ox --> (noise .2 .4 .6) 0.218519255518913 ox --> (noise (vec3 .2 .4 .6)) 0.218519255518913 ox --> (noise .5) 0.125609934329987 ox --> (noise 256.5) 0.125609934329987Return to Scheme Introduction