Last active
August 29, 2015 14:22
-
-
Save isaacabraham/3603178eae93854c5373 to your computer and use it in GitHub Desktop.
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
// 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