[taos-glug] Re: Exercises 1.40-1.46? Better web pages with Scheme?

  • From: Jonathan Bartlett <johnnyb@xxxxxxxxxx>
  • To: taos-glug@xxxxxxxxxxxxx
  • Date: Thu, 7 Aug 2003 07:58:24 -0700 (PDT)

> Has anybody tried exercises 1.40-1.46 in SICP?
>

These are the good ones, where the power of scheme shines.  Although these
are academic, this is the beginning of truly useful, pluggable software.

The answers are fairly simply, especially to the first few.

Double actually could be a useful function in general.  In fact, if you
look at these procedural functions, they make no assumptions about the
arguments.

I think scheme really wierds people out because of the ability to return
new functions, and that variables hold functions and data equally.

Anyway, this could be used for incremental optimizations.  Let's say that
you had a compiler that had an optimization stage, which you wanted to run
multiple times (to be sure than any resulting optimizations didn't have
optimizations).  If your optimization process was called using (optimize
the-code), you could run it in two passes using ((double optimize)
the-code).

(define double (lambda (orig-function)
        (lambda (x)
                (orig-function (orig-function x))
        )
))





Other related posts: