Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The barber or springfield
type Simpson = int
let [<Literal>] Homer : Simpson = 0
let [<Literal>] Bart : Simpson = 1
let [<Literal>] Lisa : Simpson = 2
// so heres the story:
// Bart shaves hisself,
// Lisa does not shave anyone
// and Homer shaves everyone who does not shave himself
let rec shaves b a =
match a with
| Bart -> b = Bart
| Lisa -> false
| Homer -> not (b |> shaves b)
| _ -> false
// so let's see
let isShavedByHomer a =
Homer |> shaves a
isShavedByHomer Bart // nope
isShavedByHomer Lisa // err what?
isShavedByHomer Homer // DOH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.