Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. let (|A|B|C|) c =
  2. if (c = 'a') then A
  3. else if (c = 'b') then B
  4. else C
  5.  
  6. let (|A|B|D|) c =
  7. if (c = '1') then A
  8. else if (c = '2') then B
  9. else D
  10.  
  11. let check myvar =
  12. match myvar with
  13. | A -> printf "match An"
  14. | n -> printf "match other %An" n
  15.  
  16. check 'x' // match other 'x'
  17. check 'a' // match other 'a' !!
  18. check '1' // match A
  19.  
  20. module Pat1 =
  21. let (|A|B|C|) c =
  22. if (c = 'a') then A
  23. else if (c = 'b') then B
  24. else C
  25.  
  26. module Pat2 =
  27. let (|A|B|D|) c =
  28. if (c = '1') then A
  29. else if (c = '2') then B
  30. else D
  31.  
  32. let check myvar =
  33. match myvar with
  34. | Pat1.A -> printf "match An"
  35. | n -> printf "match other %An" n
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement