Continued fraction/Arithmetic/G(matrix ng, continued fraction n1, continued fraction n2): Difference between revisions
Continued fraction/Arithmetic/G(matrix ng, continued fraction n1, continued fraction n2) (view source)
Revision as of 13:39, 10 March 2023
, 1 year ago→{{header|Scheme}}
Line 4,193:
(lambda (x y)
(let ((term (cf-ref cf i)))
(set! i (+ i 1))
term))))
(define no-terms-source (lambda () #f))
(define ng ng8)
(define xsource (
(define ysource (
▲ (define ix 0)
;; The procedures "main", "compare-quotients",
Line 4,238 ⟶ 4,245:
(define-values (a12 a1 a2 a b12 b1 b2 b)
(apply values ng))
(define term (xsource
▲ (set! ix (+ ix 1))
(if term
(let ((new-ng (list (+ a2 (* a12 term))
Line 4,252 ⟶ 4,258:
;; Replace the x source with one that returns no
;; terms.
(set! xsource
(set! ng (list a12 a1 a12 a1 b12 b1 b12 b1)))))
(set! ng (list a12 a1 a12 a1 b12 b1 b12 b1)))
Line 4,260 ⟶ 4,266:
(define-values (a12 a1 a2 a b12 b1 b2 b)
(apply values ng))
(define term (ysource
▲ (set! iy (+ iy 1))
(if term
(let ((new-ng (list (+ a1 (* a12 term)) a12
Line 4,272 ⟶ 4,277:
;; Replace the y source with one that returns no
;; terms.
(set! ysource
(set! ng (list a12 a12 a2 a2 b12 b12 b2 b2)))))
(set! ng (list a12 a12 a2 a2 b12 b12 b2 b2)))
|