Created
June 25, 2015 06:10
-
-
Save CarstenKoenig/bf9122448ba747b979ed to your computer and use it in GitHub Desktop.
The barber or springfield
This file contains 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 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