Sunday, September 11, 2005

Spent the weekend doing my scheme assignment. More precisely spent most of the weekend thinking about how to write a macro for letrec. No clean solutions yet.

However, I see that there is a class of problems that need *something* extra to be solved. Its all guesswork at this stage, so I could be totally off the mark.
Here's a simple problem.


(let ([a 5] [b a]) ..)

A let* or a nested let will make the above assignments work by making a visible to b.  The sequential approach would require a to be defined before b or b to be within a's scope.

(let ([a 5])
    (let ([b a])
       .....
))


This would probably solve the above problem.
Now, how about


(let ([a b] [b "B"]) ...)
   
In (letrec ([x1 v1][x2 v2]...[xn vn])How can you ensure that all x's can see other x's?
In scheme, my guess is that this is implemented as a function [How? Dont arguments need to be evaluated then?]

An attempt to write this as a macro,
without using any side-effecting operations will prove the need for some kind of a parent structure that embeds all the variables and passes the structure around for each assignment. This problem led me to the discovery of  (1) and (2).  While the first url is very readable, the 2nd one is more complete and much less readable.

I keep trying to shut out the imperative part of my brain, How would you do this functionally?

Sunday, September 11, 2005 5:00:48 PM (US Eastern Standard Time, UTC-05:00)  #    Comments [20]TrackbackTracked by:
"how to win roulette" (how to win roulette) [Trackback]
"richmond hotels" (richmond hotels) [Trackback]
"asian porn" (Jackson_Blog) [Trackback]