mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
updating sign-rule to respect finalized SRFI 159
This commit is contained in:
parent
e921fdb95c
commit
bd78ebeed7
2 changed files with 14 additions and 5 deletions
|
@ -221,6 +221,9 @@
|
|||
;; sign
|
||||
(test "+1" (show #f (numeric 1 10 #f #t)))
|
||||
(test "+1" (show #f (with ((sign-rule #t)) (numeric 1))))
|
||||
(test "(1)" (show #f (with ((sign-rule '("(" . ")"))) (numeric -1))))
|
||||
(test "-1" (show #f (with ((sign-rule '("-" . ""))) (numeric -1))))
|
||||
(test "−1" (show #f (with ((sign-rule '("−" . ""))) (numeric -1))))
|
||||
(test "-0.0" (show #f (with ((sign-rule #t)) (numeric -0.0))))
|
||||
(test "+0.0" (show #f (with ((sign-rule #t)) (numeric +0.0))))
|
||||
|
||||
|
|
|
@ -303,11 +303,17 @@
|
|||
(define (wrap-sign n sign-rule)
|
||||
(cond
|
||||
((negative?* n)
|
||||
(if (char? sign-rule)
|
||||
(cond
|
||||
((char? sign-rule)
|
||||
(string-append (string sign-rule)
|
||||
(wrap-comma (- n))
|
||||
(string (char-mirror sign-rule)))
|
||||
(string-append "-" (wrap-comma (- n)))))
|
||||
(string (char-mirror sign-rule))))
|
||||
((pair? sign-rule)
|
||||
(string-append (car sign-rule)
|
||||
(wrap-comma (- n))
|
||||
(cdr sign-rule)))
|
||||
(else
|
||||
(string-append "-" (wrap-comma (- n))))))
|
||||
((eq? #t sign-rule)
|
||||
(string-append "+" (wrap-comma n)))
|
||||
(else
|
||||
|
|
Loading…
Add table
Reference in a new issue