Hello,
On Tue 04 May 2010 17:21, Linas Vepstas writes:
> On 4 May 2010 01:32, user8472 wrote:
>>
>> This code works fine (and computes e):
>> (define y (integral (delay dy) 1 0.001))
>> (define dy (stream-map (lambda (x) x) y))
>> (stream-ref y 1000)
>>
>> The following code *should* be iden
Hello,
On Fri 14 May 2010 23:53, user8472 writes:
> The solution is thus to wrap the defines in (lambda () ...)s.
>
>
> (define (solve f y0 dt)
> (define (y) (integral (delay (dy)) y0 dt))
> (define (dy) (stream-map f (y)))
> (y))
>
> (debug-set! stack 200)
> (stream-ref (solve (lambd
OK, I have found a solution. The point is that in section 4.2.2 of R5RS it is
explicitly stated that mutually recursive defines must not refer to those
variables. The solution is thus to wrap the defines in (lambda () ...)s.
(define (solve f y0 dt)
(define (y) (integral (delay (dy)) y0 dt))
On 10 May 2010 16:36, user8472 wrote:
> Is it possible that you first typed the (define y ...) and (define dy ...)
> things at the REPL (thereby defining them in the global environment)?
Yes. Stupid me. I admit, I just cut-n-pasted your code
into the terminal, without really thinking about what
Thanks for your response. I have tried both of your suggestions and they
don't work on Guile 1.4 and Guile 1.8.6. I have installed them using Fink on
MacOS X 10.6, all latest patches installed. Guile 1.8.7 is not yet
distributed with Fink, so I used Ubuntu Linux 10.4 with Guile 1.8.7 to test
your
BTW, this is guile version 1.8.7, for me.
--linas
On 10 May 2010 11:26, Linas Vepstas wrote:
> On 7 May 2010 03:09, user8472 wrote:
>>
>> Please find the code for streams and the integration below.
>> ;; The troublesome procedure
>> (define (solve f y0 dt)
>> (define y (integral (delay dy) y0
On 7 May 2010 03:09, user8472 wrote:
>
> Please find the code for streams and the integration below.
> ;; The troublesome procedure
> (define (solve f y0 dt)
> (define y (integral (delay dy) y0 dt))
> (define dy (stream-map f y))
> y)
>
> ;; This works
> (define y (integral (delay dy) 1 0.001))
Please find the code for streams and the integration below. The macro
definition of cons-stream is not from SICP since it is implementation
dependent (for this reason I have also not tried the code on other Scheme
implementations except Guile). So this could be buggy.
I don't think it is only an
On 4 May 2010 11:59, user8472 wrote:
>
> becomes
> streams.scm:601:14: While evaluating arguments to stream-map in expression
> (stream-map f y):
> streams.scm:601:14: Variable used before given a value: y
> ABORT: (unbound-variable)
>
> So something is still not quite right.
My bad, I completel
Thanks for your reply. Yes, SICP introduces "let*" in chapter 4.1. The
current exercise is in chapter 3.5, though ;^)
Your suggestion is definitely a step in the right direction. However, it
does not yet solve the problem. The code
(define (solve f y0 dt)
(let* ((y (integral (delay dy) y0 d
On 4 May 2010 01:32, user8472 wrote:
>
> I am currently working through SICP using Guile. I have found some strange
> behavior when doing the exercises in chapter 3.5. I am running Guile 1.4
> installed via Fink on Mac OS X 10.6, all latest patches installed. The
> problem also exists in Guile 1.8
11 matches
Mail list logo