Skip to content

Instantly share code, notes, and snippets.

@isaacabraham
Last active August 29, 2015 14:22
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 isaacabraham/3603178eae93854c5373 to your computer and use it in GitHub Desktop.
Save isaacabraham/3603178eae93854c5373 to your computer and use it in GitHub Desktop.
// Determine the next command given a current state
let (|SpeedUp|SlowDown|DoNothing|Jump|) bikeState =
match bikeState, bikeState.Speed with
| OnTheRunway, TooSlow -> SpeedUp
| OnTheRunway, TooFast -> SlowDown
| OnTheRunway, TargetSpeed | InFlight, _ -> DoNothing
| JustBeforeGap, _ -> Jump
| AfterGap, _ -> SlowDown
// translate our domain model into a format for the interpreter
match bikeState with
| SpeedUp -> "SPEED"
| SlowDown -> "SLOW"
| DoNothing -> "WAIT"
| Jump -> "JUMP"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment