This comment is reply for 182 katsu: schemeですけど、gaucheでしか...(分数を小数に展開). Go to thread root.
katsu #218(2007/07/06 06:04 GMT) [ Scheme ] Rating0/0=0.00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
(use text.tree) (use srfi-1) (use srfi-11) (use gauche.sequence) (define (div3 a b) (tree->string (cons "0." (let loop ((a (* 10 a)) (b b) (r ()) (l ())) (cond ((find-index (pa$ = a) l) => (lambda (m) (reverse (call-with-values (cut split-at r (+ m 1)) (cut append '("}") <> '("{") <>))))) ((< a b) (loop (* a 10) b (cons 0 r) (cons a l))) (else (let-values (((quo rem) (quotient&remainder a b))) (if (zero? rem) (reverse (cons quo r)) (loop (* rem 10) b (cons quo r) (cons a l))))))))))
Rating0/0=0.00-0+
[ reply ]
katsu
#218()
[
Scheme
]
Rating0/0=0.00
Rating0/0=0.00-0+