Continued fraction/Arithmetic/Construct from rational number: Difference between revisions
Content added Content deleted
Line 4,571: | Line 4,571: | ||
(if (zero? d) |
(if (zero? d) |
||
(call-with-current-continuation |
(call-with-current-continuation |
||
(lambda ( |
(lambda (kont) |
||
(call-with-values (lambda () (values |
(call-with-values (lambda () (values #f kont)) |
||
consumer))) |
consumer))) |
||
(let-values (((q r) (floor/ n d))) |
(let-values (((q r) (floor/ n d))) |
||
(loop d r (call-with-current-continuation |
(loop d r (call-with-current-continuation |
||
(lambda ( |
(lambda (kont) |
||
(call-with-values (lambda () |
(call-with-values (lambda () |
||
(values |
(values q kont)) |
||
consumer))))))))) |
consumer))))))))) |
||
(define (display-cf |
(define (display-cf term producer) |
||
(display "[") |
(display "[") |
||
(let loop (( |
(let loop ((term term) |
||
( |
(producer producer) |
||
(separator "")) |
(separator "")) |
||
(if term |
(if term |
||
Line 4,590: | Line 4,590: | ||
(display separator) |
(display separator) |
||
(display term) |
(display term) |
||
(let-values ((( |
(let-values (((term producer) |
||
(call-with-current-continuation producer))) |
(call-with-current-continuation producer))) |
||
(loop |
(loop term producer |
||
(if (string=? separator "") ";" ",")))) |
(if (string=? separator "") ";" ",")))) |
||
(begin |
(begin |