- [Function]
(
pickl
list {keyword value}*)
Returns a randomly selected element from list according to the keyword arguments specified to the function.
pick
supports the following keyword arguments:
:start
integer- An optional lower bound on element selection.
:end
integer- An optional exclusive upper bound on element selection.
:avoid
datum- A datum in list to exclude from selection.
:state
random-state- The random state to use. The default value is
*random-state*
.
Examples:
Example 1. The pickl
function.
(pickl '(1 2 3 4 5)) ⇒ 3 (pickl '(1 2 3) :avoid 3) ⇒ 1 (pickl '(1 2 3 4 5) :start 1 :end 4) ⇒ 3 (pickl '(1 2 3 4 5) :start 1 :end 4) ⇒ 4
Example 2. Random selection with pickl
.
(define (play-pickl len keys nums rhys amps) (process repeat len for r = (pickl rhys) for a = (pickl amps) each n below (pickl nums) as k = (pickl keys :avoid k) output (new midi :time (now) :keynum k :duration (* r (pickl '(.5 1.5)))) wait r)) (events (play-pickl 60 '(60 62 63 65 67 68 70 72) '(1 2 3) '(.1 .2 .2 .2 .4) '(.2 .4 .5 )) "test.mid") ⇒ "test.mid"