From dc56ab709052bbee685d5809937891e9b2ee73cd Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Sat, 27 Apr 2013 18:02:22 -0700 Subject: [PATCH] planetarium: Use r3rs-number->string, just with (int) format. Only integers formatted per the (int) specification are supported. --- src/planetarium/geometry.scm | 8 +++++--- src/planetarium/mit-r3rs.scm | 5 ++++- src/planetarium/tellurion.scm | 16 ++++++++++------ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/planetarium/geometry.scm b/src/planetarium/geometry.scm index fabdf65d2..45a9f90dc 100644 --- a/src/planetarium/geometry.scm +++ b/src/planetarium/geometry.scm @@ -71,9 +71,11 @@ USA. (let* ((deg.r (integer-divide (abs degrees) 3600)) (min.r (integer-divide (cdr deg.r) 60))) (string-append (if (negative? degrees) "-" "+") - (number->string (car deg.r)) - ":"(string-pad-left (number->string (car min.r)) 2 #\0) - ":"(string-pad-left (number->string (cdr min.r)) 2 #\0)))) + (number->string (car deg.r) '(int)) + ":"(string-pad-left (number->string (car min.r) '(int)) + 2 #\0) + ":"(string-pad-left (number->string (cdr min.r) '(int)) + 2 #\0)))) (define (lesser-angle a b) ;; Angle B translated to (not more than 2pi) numerically less than A. diff --git a/src/planetarium/mit-r3rs.scm b/src/planetarium/mit-r3rs.scm index 481c9b8f3..6d70a0152 100644 --- a/src/planetarium/mit-r3rs.scm +++ b/src/planetarium/mit-r3rs.scm @@ -62,7 +62,10 @@ USA. (string-append a b)) (define (r3rs-number->string number format) - (error "Unimplemented: r3rs-number->string:" number format)) + (if (not (and (equal? format '(int)) + (integer? number))) + (warn "Unimplemented: r3rs-number->string:" number format)) + (number->string number)) (define (r3rs-string->number string exactness radix) (let ((n (string->number string (case radix diff --git a/src/planetarium/tellurion.scm b/src/planetarium/tellurion.scm index f8343e567..155435f5b 100644 --- a/src/planetarium/tellurion.scm +++ b/src/planetarium/tellurion.scm @@ -148,18 +148,22 @@ USA. (string-append (cond ((flo:negative? lat) "S") ((flo:positive? lat) "N") (else "")) - (number->string lat-deg) + (number->string lat-deg '(int)) "°" - (string-pad-left (number->string lat-min) 2 #\0) + (string-pad-left (number->string lat-min '(int)) + 2 #\0) "." - (string-pad-left (number->string lat-frac) 3 #\0) + (string-pad-left (number->string lat-frac '(int)) + 3 #\0) "' " (cond ((flo:negative? long) "W") ((flo:positive? long) "E") (else "")) - (number->string long-deg) + (number->string long-deg '(int)) "°" - (string-pad-left (number->string long-min) 2 #\0) + (string-pad-left (number->string long-min '(int)) + 2 #\0) "." - (string-pad-left (number->string long-frac) 3 #\0) + (string-pad-left (number->string long-frac '(int)) + 3 #\0) "'"))))))) \ No newline at end of file -- 2.25.1