commit 2d4aae6cc66401191987352ceb9a6fef3a855f0e parent ed2c52b3d83ec9f986c10183b7934dacc94d3164 Author: Andrew Laack <andrew@laack.co> Date: Wed, 23 Sep 2026 21:32:26 -0500 Basic variant usage Diffstat:
| A | ch3/follow-along/day-of-week.ml | | | 25 | +++++++++++++++++++++++++ |
1 file changed, 25 insertions(+), 0 deletions(-)
diff --git a/ch3/follow-along/day-of-week.ml b/ch3/follow-along/day-of-week.ml @@ -0,0 +1,25 @@ +type day = + | Sun + | Mon + | Tue + | Wed + | Thu + | Fri + | Sat + +let day_to_int day = + match day with + | Sun -> 1 + | Mon -> 2 + | Tue -> 3 + | Wed -> 4 + | Thu -> 5 + | Fri -> 6 + | Sat -> 7 + +let run = + let d = Tue in + print_int (day_to_int d); + print_newline ();; + +run