Last active
August 29, 2015 14:14
-
-
Save bjartwolf/d59f8e5e3f6a8e68e50e to your computer and use it in GitHub Desktop.
kebabs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Rod = Dagger | Sword | Fork | |
type Plate = GoldPlate | SilverPlate | BronzePlate | |
type Bottom = Rod | Plate | |
type shish<'A> = | |
Bottom of 'A | |
| Onion of shish<'A> | |
| Lamb of shish<'A> | |
| Tomato of shish<'A> | |
let rec isVeg kebab = | |
match kebab with | |
| Bottom (x) -> true | |
| Onion (x) -> isVeg x | |
| Lamb (x) -> false | |
| Tomato (x) -> isVeg x | |
let aBab = Onion(Tomato (Onion(Bottom GoldPlate))) | |
let anotherBab = Onion(Lamb(Onion(Tomato(Bottom 53)))) | |
(isVeg aBab).Dump() | |
(isVeg anotherBab).Dump() | |
let rec WhatBottom kebab = | |
match kebab with | |
| Bottom (x) -> x | |
| Onion (x) -> WhatBottom x | |
| Lamb (x) -> WhatBottom x | |
| Tomato (x) -> WhatBottom x | |
(WhatBottom aBab).Dump() | |
(WhatBottom anotherBab).Dump() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment