Posted to tcl by kbk at Fri Jul 18 21:43:02 GMT 2008view raw

  1. proc fact3 {n c} {
  2. if {$n == 0} {
  3. {*}$c 1
  4. } else {
  5. tailcall fact3 [- $n 1] \
  6. [list apply {{n c f} {
  7. puts [list continuation $c will get the product of $n and $f]
  8. {*}$c [* $n $f]
  9. }} $n $c]
  10. }
  11. }
  12. fact3 6 puts