From: Matthias Felleisen (matthias at ccs.neu.edu) Date: Sun Aug 1 22:46:31 EDT 2010 |
|
On Aug 1, 2010, at 8:05 PM, Todd O'Bryan wrote: > In a language with typing and > overloading, you could define two distance functions, one that takes > two posns and another that takes four numbers, and I think this would > be the most natural way to write distance. Like this: (define distance (case-lambda ((p q) (distance (posn-x p) (posn-x q) (posn-y p) (posn-y q))) ((x0 y0 x1 y1) (sqrt (+ (sqr (- x0 y0)) (sqr (- x1 y1))))))) (distance (posn 3 4) (posn 0 0))
Posted on the users mailing list. |
|