[racket] SICP (again)
Why not just do:
(define (square x)
(* x x))
?
On Wed, 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
>
--
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/