|
Subject: Re: Question: Tokenizing CDATA attribute values From: David Megginson <dmeggins@xxxxxxxxxx> Date: Mon, 16 Jun 1997 14:08:36 -0400 |
W. Eliot Kimber writes:
> While we're on the subject, can someone provide (or point me to) a
> brief tutorial on the distinction between a simple define, "let"
> procedures, and "lambda" procedures? I seem to be being
> particularly dim about these--probably too many years of procedural
> programming to see the obvious in a scheme context.
The tricky part is that I was using named let (ISO/IEC 10179:1996,
clause 8.3.2.6). When I do
(let X ((a 10)
(b 20))
...
)
I'm not only creating new bindings for the variables "a" and "b", but
I'm binding X to a new function that takes "a" and "b" as arguments,
so that I can call (X ...) recursively to start a new iteration of the
loop (remember that tail-recursion is better than iteration in
Scheme). In other words, the best equivalent for
for (x = 0; x < 100; x++) {
foo(x);
}
in Scheme is
(let loop-function ((x 0))
(cond ((< x 100)
(foo x)
(loop-function (+ x 1)))))
It looks a little clumsy for straight-forward iteration, but it's very
nice for working through lists, etc.
All the best,
David
--
David Megginson ak117@xxxxxxxxxxxxxxxxxxx
Microstar Software Ltd. dmeggins@xxxxxxxxxxxxx
University of Ottawa dmeggins@xxxxxxxxxx
http://www.uottawa.ca/~dmeggins
DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: Question: Tokenizing CDATA attr, W. Eliot Kimber | Thread | loops/tail recusion, Dave Love |
| Re: Question: Tokenizing CDATA attr, W. Eliot Kimber | Date | Re: Question: Tokenizing CDATA attr, Paul Prescod |
| Month |