[Function]
(between lb ub [avoid] [state])

Returns a random number equal to or greater than lb but less than ub. If both lb and ub are integers then an integer value is returned, otherwise a floating point value is returned. If avoid is specified then the random value selected will not equal it. The optional random state defaults to *random-state*.

Examples:

Example 1. Random selection using between.

(between 1 3)
 2
(between 1 2.0)
 1.8205206
(between 1 1)
 1
;;; random integers without direct repetition
(loop repeat 10 for n = (between 1 5 n) collect n)
 (4 2 3 4 1 4 2 3 1 4)

Example 2. A random process using between.

(define (play-between lo hi k1 k2 r1 r2 a1 a2 c1 c2)
  (process repeat (between lo hi)
           for k = (between k1 k2 k) ; no repeated note
           for r = (between r1 r2)
           for d = (* r (between .5 1.5))
           for a = (between a1 a2)
           for c = (between c1 c2)
           output (new midi :time (now) 
                       :keynum k
                       :amplitude a 
                       :duration d)
           wait r))

(events (play-between 10 20 30 60 .5 1.5 .2 .8 0 6)
        "test.mid")
 "test.mid"

See also: