Advertisement
Guest User

Untitled

a guest
Apr 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. type Meal =
  2. | Breakfast of string
  3. | Lunch of string
  4. | Dinner of string
  5.  
  6.  
  7.  
  8. let interpretMeal meal =
  9. match meal with
  10. | Breakfast("Havregroed") -> "EN: Oatmeal is a delicious breakfast"
  11. | Lunch("Fisk") -> "EN: Fish is a delicious lunch"
  12. | Lunch("Rugbrød") -> "EN: rye bread is the most popular bread in Denmark"
  13. | Dinner("Frikadeller") -> "EN: meat balls are a delicious dinner"
  14. | Dinner("Tarteletter") -> "EN: tartlets is delicious dinner dish"
  15. | _ -> "Unknown dish"
  16.  
  17. // test
  18. interpretMeal (Breakfast("Havregroed"))
  19.  
  20.  
  21. type Sports =
  22. |Individual of string
  23. |Team of string * int
  24.  
  25. let interpretSport sport =
  26. match sport with
  27. |Team("Ôóòáîë", 11) -> "EN: The Englis sport Football with 11 players "
  28. |Team("Áàñêåòáîë", 5) ->"EN: American sport Basketball with 5 payers"
  29. |Team ("Õîêåé",6) -> "EN: Canadian sport Hockey with 6 players"
  30. |Individual ("Ãîëô") -> "EN: Golf"
  31. |Individual("Òåíèñ") -> "EN: Tennis"
  32. |_ -> "Unknown"
  33.  
  34. // test
  35. interpretSport (Individual("Ãîëô"));;
  36. interpretSport (Team ("Õîêåé",6));;
  37.  
  38.  
  39.  
  40. let interpretAgentMeal =
  41. MailboxProcessor.Start(fun inbox->
  42. let rec msgLoop = async{
  43. let! meal = inbox.Receive()
  44. printfn "%s" (interpretMeal meal)
  45. return! msgLoop
  46. }
  47. msgLoop)
  48.  
  49.  
  50.  
  51. interpretAgentMeal.Post (Breakfast("Havregroed"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement