[plt-scheme] (let ((+ +) ...
Use modules.
On Apr 1, 2008, at 1:29 PM, Majorinc, Kazimir wrote:
> I do not like how redefinition of + changes the function "distance":
>
>
> > (define distance (lambda (x y)(sqrt (+ (* x x)(* y y)))))
> > (distance 4 3)
> 5
> > (define + -)
> > (distance 4 3)
> 2.6457513110645907
>
>
> It can be solved with:
>
>
> > (define distance (let ((+ +)(* *)(sqrt sqrt))
> (lambda(x y)(sqrt (+ (* x x)(* y y))))))
> > (distance 4 3)
> 5
> > (define + -)
> > (distance 4 3)
> 5
> >
>
> Is there any better way to accomplish the same?
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme