Skip to content

Instantly share code, notes, and snippets.

@CarstenKoenig
Created June 25, 2015 06:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CarstenKoenig/bf9122448ba747b979ed to your computer and use it in GitHub Desktop.
Save CarstenKoenig/bf9122448ba747b979ed to your computer and use it in GitHub Desktop.
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