[racket] SICP (again)

From: Alexander McLin (alex.mclin at gmail.com)
Date: Wed Nov 26 07:17:20 EST 2014

The square function is also defined in earlier SICP sections so I would recommend you maintain a running file of all functions SICP defines so you can refer back to them easily.



> On Nov 26, 2014, at 5:37 AM, Catonano <catonano at gmail.com> wrote:
> 
> Hello 
> 
> I understand that this is not the first time someone asks about using Racket for a SICP study group.
> 
> I used the not so mantained mit-scheme compatibility package and I tried to paste this piece of code
> 
> 
> 
> (define (average x y)
>     (/ (+ x y) 2))
>     
> (define (sqrt x)
>     (define (improve guess)
>         (average guess (/ x guess )))
>     (define (good-enough? guess)
>         (< (abs (- (square guess) x )) .001))
>     (define (try guess)
>                 
>         (if (good-enough? guess)
>         guess
>             (try (improve guess))))
>         (try 1))
> 
> 
> It should be the Newton's method to calculate the square root
> 
> We copied it from the lectures
> 
> In this code we use the "square" function. In mit-scheme it's ok, in Racket it's not defined
> 
> Should I import any module ?
> 
> Are common functions named as in mit-scheme ? Or are we gonna run into compatibility issues ?
> 
> Thanks for any hint
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users


Posted on the users mailing list.