Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2019
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.53 KB | None | 0 0
  1. (define (square x) (* x x))
  2. (define (sum-of-squares a b) (+ (square a) (square b)))
  3.  
  4. (define (sum-of-largest-squares x y z)
  5.   (cond ((and (< x y) (< y z))) ((sum-of-squares y z))
  6.         ((and (> x y) (< x z))) ((sum-of-squares x z))
  7.         ((and (> x z) (< x y))) ((sum-of-squares x y))
  8.     ))
  9.  
  10. (sum-of-largest-squares 1 2 3)
  11. (sum-of-largest-squares 1 3 2)
  12. (sum-of-largest-squares 2 1 3)
  13. (sum-of-largest-squares 2 3 1)
  14. (sum-of-largest-squares 3 2 1)
  15. (sum-of-largest-squares 3 1 2)
  16.  
  17. ;;; Output
  18. #|
  19. #t
  20. 13
  21. 10
  22. 10
  23. 5
  24. 5
  25. |#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement