[ prog / sol / mona ]

prog


Internal definitions vs letrec

2 2020-08-01 21:25

I believe letrec is older than internal defines, although it does introduce unnecessary nesting. Here's a nicer way to write the latter:

(define (fibonacci n)
  (letrec ((fibonacci (lambda (n a b)
                        (cond
                         ((zero? n) b)
                         (else (fibi (- n 1) (+ a b) a))))))
    (fibonacci n 1 0)))
13


VIP:

do not edit these