[plt-scheme] (let ((+ +) ...
Majorinc, Kazimir
kazimir at chem.pmf.hr
Tue Apr 1 13:29:05 EDT 2008
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?
More information about the plt-scheme
mailing list