Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 0.61 KB | None | 0 0
  1. ;; ====== Problem 5.2 ======
  2. ;; creation of predicates
  3.  
  4. ;; categorie=?: product symbol -> bool
  5. ;;
  6. ;; example: (categorie=? tea 'drink) ergibt true
  7. (define (categorie=? prod categ)
  8.   (if (symbol=? (product-categorie prod) categ) true
  9.       false)
  10.   )
  11.  
  12. ;; cheaper?: product number -> bool
  13. ;;
  14. ;; example: (cheaper? apple 0.5) ergibt false
  15. (define (cheaper? prod value)
  16.   (if (< (product-price prod) value) true
  17.       false)
  18.   )
  19.  
  20. (check-expect (categorie=? apple 'fruit) true)
  21. (check-expect (categorie=? tea 'fruit) false)
  22. (check-expect (cheaper? apple 0.5) false)
  23. (check-expect (cheaper? banana 55) true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement