Advertisement
cardel

Ejercicio FP 11 Junio

Jun 11th, 2019
1,070
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 0.46 KB | None | 0 0
  1. ;;Propósito: Calcular la distancia entre dos puntos
  2. ;;(calcular-distancia (make-posn 1 2) (make-posn 2 2)) -> 1
  3. ;;(calcular-distancia (make-posn 3 -4) (make-posn 5 8))  #i12.165525060596439
  4. (define (calcular-distancia p1 p2)
  5.   (sqrt
  6.    (+
  7.     (sqr (- (posn-x p1) (posn-x p2)))
  8.     (sqr (- (posn-y p1) (posn-y p2)))
  9.     )))
  10.  
  11. ;;Pruebas
  12. (check-expect (calcular-distancia (make-posn 1 2) (make-posn 2 2)) 1)
  13. (calcular-distancia (make-posn 3 -4) (make-posn 5 8))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement