Advertisement
Guest User

cards

a guest
Apr 6th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. datatype suit = Clubs of string
  2.               | Diamonds of string
  3.               | Hearts of string
  4.               | Spades of string;
  5. datatype rank = Jack of string
  6.               | Queen of string
  7.               | King of string
  8.               | Ace of string
  9.               | Num of int;
  10. type card = suit * rank;
  11.  
  12. fun card_color c =
  13.     case c of
  14.        Clubs _=> "Black"
  15.      | Diamonds _=> "Red"
  16.      | Hearts _=> "Red"
  17.      | Spades _=> "Black";
  18.  
  19.  
  20. fun card_value c =
  21.     case c of
  22.        Jack  _=> 10
  23.      | Queen _=> 10
  24.      | King _=> 10
  25.      | Ace _=> 10
  26.      | Num n=> n;
  27.  
  28. fun remove_card (cl: card list, c : card) =
  29.     case cl of
  30.         []=>[]
  31.         | xs::ys => if c = xs then remove_card(c,ys)
  32.                     else xs::remove_card(c,ys);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement