Continued fraction/Arithmetic/Construct from rational number: Difference between revisions

Line 494:
(for/list ([i (in-producer (r2cf n d) null)])
i))
 
(map r->cf
(list 1 3 23 13 22 -151)
(list 2 1 8 11 7 77))
 
(define (real->cf x places)
Line 503 ⟶ 499:
[n (exact-floor (* x d))])
(r->cf n d)))
 
(map r->cf
(list 1 3 23 13 22 -151)
(list 2 1 8 11 7 77))
 
(real->cf (sqrt 2) 10)
(real->cf pi 10)</lang>
 
{{out}}
 
<pre>
'((0 2) (3) (2 1 7) (1 5 2) (3 7) (-1 -1 -24 -1 -2))
'(1 2 2 2 2 2 2 2 2 2 2 2 2 3 3 1 3 8 9 1 20 1 2)
'(3 7 15 1 292 1 1 6 2 13 3 1 12 3)
</pre>
 
=={{header|REXX}}==
Anonymous user