In OCaml, you are able to create your own Types. In other languages, you can thing of these like enums. You can see how these are created and how they can be used with Pattern Matching.
type month = |Jan |Feb |Mar |Apr |May |Jun |Jul |Aug |Sep |Oct |Nov |Dec ;; let monthNum month = match month with |Jan -> 1 |Feb -> 2 |Mar -> 3 |Apr -> 4 |May -> 5 |Jun -> 6 |Jul -> 7 |Aug -> 8 |Sep -> 9 |Oct -> 10 |Nov -> 11 |Dec -> 12 ;; monthNum Nov;;
Screen Shot 2014-11-02 at 21.20.33.png 81.47KB 0 downloads