Posted to tcl by kbk at Fri Jul 18 21:43:02 GMT 2008view raw
- proc fact3 {n c} {
- if {$n == 0} {
- {*}$c 1
- } else {
- tailcall fact3 [- $n 1] \
- [list apply {{n c f} {
- puts [list continuation $c will get the product of $n and $f]
- {*}$c [* $n $f]
- }} $n $c]
- }
- }
- fact3 6 puts