Posted to tcl by oldlaptop at Fri Dec 19 00:52:45 GMT 2025view raw

  1. set fib {{n} {
  2. if {$n == 0} {
  3. return 0
  4. } elseif {$n == 1} {
  5. return 1
  6. } else {
  7. set self [dict get [info frame 0] lambda]
  8. ::tcl::mathop::+ \
  9. [apply $self [expr {$n - 1}]] \
  10. [apply $self [expr {$n - 2}]]
  11. }
  12. }}
  13.  
  14. apply $fib 8

Add a comment

Please note that this site uses the meta tags nofollow,noindex for all pages that contain comments.
Items are closed for new comments after 1 week