;; select random pitch from pitch class
;; bounded by lower and upper (inclusive lower exclusive upper)
;;
;; arg 1: lower bound (inclusive)
;; arg 2: upper bound (exclusive)
;; arg 3: pitch class
;;
;; returns #f if no valid pitch is possible
;;
(define pc:random
(lambda (lower upper pc)
(if (null? pc) #f
(let ((choices (filter (lambda (x) (pc:? x pc)) (range lower upper))))
(if (null? choices) #f
(random choices))))))