Posted to tcl by kbk at Tue Aug 17 22:37:31 GMT 2010view pretty
proc cfhomo {a b c d x} { while {1} { # Egest what terms we can while {1} { set prod [* $c $d] if {$prod == Inf || $prod <= 0} break set qcoef [/ $a $c] set rcoef [% $a $c] set qconst [/ $b $d] set rconst [% $b $d] if {$qconst != $qcoef} break Yield $qconst [list $x 1] lassign [list $c $d $rcoef $rconst] a b c d } # Ingest the next term of the input set t [$x] if {$t == Inf} { tailcall cfint/int $a $c } lassign [list [expr {$t*$a + $b}] $a [expr {$t*$c + $d}] $c] a b c d } }