All pastes #523483 Raw Edit

Mine

public text v1 · immutable
#523483 ·published 2007-05-30 20:10 UTC
rendered paste body
(define (normalize n mult)
  (cond 
   ((=  n 0)   (list 0 1))
   ((>= n 1)   (normalize (* n 0.1) (* mult 10 )))
   ((< n  0.1) (normalize (* n 10 ) (* mult 0.1)))
   (else (list n mult))))

(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)))))))