Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;Propósito: Calcular la distancia entre dos puntos
- ;;(calcular-distancia (make-posn 1 2) (make-posn 2 2)) -> 1
- ;;(calcular-distancia (make-posn 3 -4) (make-posn 5 8)) #i12.165525060596439
- (define (calcular-distancia p1 p2)
- (sqrt
- (+
- (sqr (- (posn-x p1) (posn-x p2)))
- (sqr (- (posn-y p1) (posn-y p2)))
- )))
- ;;Pruebas
- (check-expect (calcular-distancia (make-posn 1 2) (make-posn 2 2)) 1)
- (calcular-distancia (make-posn 3 -4) (make-posn 5 8))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement