(define (weighted-selection . args) (let ((rand (random))) (let loop ((lst args) (count 0)) (if (< rand (+ count (caar lst))) (cdar lst) (loop (cdr lst) (+ count (caar lst)))))))