[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Difference letrec & environment binding

From: Hans Aberg
Subject: Difference letrec & environment binding
Date: Wed, 13 Apr 2011 12:38:07 +0200

What is the practical difference between the two ways of doing the same thing 
(letrec or an environment). Is letrec more efficient in the implementation of 


(letrec (
  (even? (lambda (n)
    (if (zero? n) #t (odd? (- n 1)))))
  (odd? (lambda (n)
    (if (zero? n) #f (even? (- n 1))))))
  (even? 1000))

((lambda ()
  (define even? (lambda (n)
    (if (zero? n) #t (odd? (- n 1)))))
  (define odd? (lambda (n)
    (if (zero? n) #f (even? (- n 1)))))
  (even? 1000)))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]