arc> (do (to-N-places 5.123456789 5) (prn)) 5.12345 nil
(def to-N-places (f (o N 3)) (let s (string (to-nearest f (expt 10.0 (- N)))) (cut s 0 (min (+ N 1 (pos #\. s)) (len s))))) arc> (to-N-places 5.123456789 5) "5.12346"
Personally, I think we really need CL-style format.
arc> ($ (require (lib "48.ss" "srfi"))) #<void> arc> (def format args ($ (format ,@args))) #<procedure: format> arc> (format "~4,4F" (sqrt 2)) "1.4142"
-----