Anonymous user
Continued fraction/Arithmetic/Construct from rational number: Difference between revisions
Continued fraction/Arithmetic/Construct from rational number (view source)
Revision as of 11:49, 10 March 2013
, 11 years ago→{{header|Tcl}}: minor tweaks for readability
(→Tcl: Added implementation) |
m (→{{header|Tcl}}: minor tweaks for readability) |
||
Line 390:
set n2 [expr {$n2 * 10**$pow}]
}
coroutine cf\#[incr ::cfcounter] apply {{n1 n2} {
yield [info coroutine]
while {$n2 > 0} {
Line 400:
}</lang>
Demonstrating:
<lang tcl>
while 1 {
puts -nonewline "[$cf],"
}
puts "\b "
}
foreach {n1 n2} {
1 2
3 1
Line 421 ⟶ 429:
3141592653589793 1000000000000000
} {
▲ while 1 {puts -nonewline [$cf],};puts "\b "
}</lang>
{{out}}
|