unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Difference letrec & environment binding
@ 2011-04-13 10:38 Hans Aberg
  2011-04-13 11:51 ` dsmich
  0 siblings, 1 reply; 2+ messages in thread
From: Hans Aberg @ 2011-04-13 10:38 UTC (permalink / raw)
  To: guile-devel

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 Guile?

Hans


(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)))





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-13 11:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-13 10:38 Difference letrec & environment binding Hans Aberg
2011-04-13 11:51 ` dsmich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).