(define (normalize-impl n mult) (cond ((= n 0) (list 0 1)) ((>= n 1) (normalize-impl (* n 0.1) (* mult 10 ))) ((< n 0.1) (normalize-impl (* n 10 ) (* mult 0.1))) (else (list n mult)))) (define (normalize x) (normalize-impl x 1)) (define (nearest-impl val lst higher lower) (if (null? lst) (list higher lower) (let ((next (car lst)) (rest (cdr lst))) (cond ((< val next) (nearest-impl val rest (min higher next) lower)) (else (nearest-impl val rest higher (max lower next))))))) (define (nearest val lst) (nearest-impl val lst (apply max lst) (apply min lst))) (define (preferred val series) (let* ((nlst (normalize val)) (n (car nlst)) (m (cadr nlst))) (map (lambda (x) (* x m)) (nearest n series)))) (display (preferred 0.4 '(.1 .2 .3 .35 .45 .8 .9)))