Created
September 25, 2018 17:48
-
-
Save WhoAteDaCake/30b474652abf690cf851d2fc5864530b to your computer and use it in GitHub Desktop.
Rain
This file contains hidden or 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
module Rain = { | |
/* All measurements are in mm */ | |
module Hourly = { | |
let light = 2.5; | |
let moderate = 7.6; | |
let heavy = 50.0; | |
let violent = 100.0; | |
}; | |
module Daily = { | |
let light = 2.5 *. 24.0; | |
let moderate = 7.6 *. 24.0; | |
let heavy = 50.0 *. 24.0; | |
let violent = 100.0 *. 24.0; | |
}; | |
let score_to_text = n => | |
switch (n) { | |
| 0 => "Light" | |
| 1 => "Moderate" | |
| 2 => "Heavy" | |
| _ => "Violent" | |
}; | |
let hourlyIntensity = mm => | |
Hourly.( | |
if (mm < light) { | |
0; | |
} else if (mm < moderate) { | |
1; | |
} else if (mm < heavy) { | |
2; | |
} else { | |
3; | |
} | |
); | |
let dailyIntensity = mm => | |
Daily.( | |
if (mm < light) { | |
0; | |
} else if (mm < moderate) { | |
1; | |
} else if (mm < heavy) { | |
2; | |
} else { | |
3; | |
} | |
); | |
let intensity = (daily, hourly) => | |
max(dailyIntensity(daily), hourlyIntensity(hourly)) |> score_to_text; | |
}; |
Author
WhoAteDaCake
commented
Sep 25, 2018
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment