boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

20-letrec.scm (365B)


      1 ; letrec: a local helper that calls itself. The closure must see its own
      2 ; binding via the captured env. Real recursion -- factorial walks the
      3 ; stack down to the base case and back, so a one-step bug would not
      4 ; produce 120.
      5 (sys-exit (letrec ((fact (lambda (n)
      6                            (if (= n 0) 1 (* n (fact (- n 1)))))))
      7             (fact 5)))   ; 5! = 120