Home > Archive > Scheme > January 2008 > iteration - do with let
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
iteration - do with let
|
|
| S. Robert James 2008-01-22, 7:35 pm |
| I'd like to use the do iteration form. However, I'd like to update
several of the variables based on an intermediate variable, which do
doesn't seem to be able to support. That is, define a let body in
which the do step-updates are evaluated.
(I could do this by putting a set! in the command clause - but I'd
like to avoid use of set!).
Any solutions?
| |
| Jussi Piitulainen 2008-01-23, 4:35 am |
| S. Robert James writes:
> I'd like to use the do iteration form. However, I'd like to update
> several of the variables based on an intermediate variable, which do
> doesn't seem to be able to support. That is, define a let body in
> which the do step-updates are evaluated.
>
> (I could do this by putting a set! in the command clause - but I'd
> like to avoid use of set!).
>
> Any solutions?
If you can arrange it so that the intermediate variable is computed in
the previous iteration step, do that. Otherwise, I wouldn't use `do'
for this. It's only nice when it is nice; don't make it a mess.
Consider the `named let':
(let foo (... initial bindings ...)
... body where you can call `foo' ...)
| |
|
|
|
|
|