PasteRack.org
Paste # 35458
2019-04-25 14:29:21

Fork as a new paste.

Paste viewed 49 times.


Embed:

  1.  
  2. ; a card has a suit and a rank
  3. ; suit = 'hearts | 'diamonds | 'spades | 'clubs
  4. ; rank = 2-10 | 'jack | 'queen | 'king | 'ace
  5. (struct card (suit rank) #:transparent)
  6.  
  7. (define aceOfSpades (card 'spades 'ace))
  8. (define threeOfHearts (card 'hearts 3))
  9. (define alsoThreeOfHearts (card 'hearts 3))
  10. (define jackOfDiamonds (card 'diamonds 'jack))
  11. (define sevenOfClubs (card 'clubs 7))
  12.  
  13. ;
  14. ; 1. Rearrange the lines of the cardColor function to work correctly
  15. ; the function cardColor takes a card as an argument and returns its color (spades and clubs are black; diamonds and hearts are red)
  16. ;
  17.  
  18. ;(define (cardColor c)
  19. ;          (eq? (card-suit c) 'diamonds))
  20. ;  (if (or (eq? (card-suit c) 'hearts)
  21. ;      'black))
  22. ;      'red
  23.  
  24. (define
  25.     (if (or (eq? (card-suit c) 'hearts)
  26.         (eq? (card-suit c) 'diamonds))
  27.         'black))
  28.         'red
  29.  
  30.  
  31.  
  32. (cardColor aceOfSpades)
  33. (cardColor threeOfHearts)
  34. (cardColor jackOfDiamonds)
  35. (cardColor sevenOfClubs)

=>

load-handler: expected a `module' declaration for `pasterack' in "paste 35458", but found something else

Check that paste includes #lang?