Created
March 4, 2020 15:31
-
-
Save wspringer/d5fabacc21b48ab3d3ccaa8f92d635fb to your computer and use it in GitHub Desktop.
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
let bottles = (number) => switch(number) { | |
| 0 => "no more bottles of beer" | |
| 1 => "1 bottle of beer" | |
| n => { | |
let formatted = string_of_int(n); | |
{j|$formatted bottles of beer|j}; | |
} | |
} | |
let rec countdownFrom = (current) => current == 0 ? { | |
Js.log("No more bottles of beer on the wall, no more bottles of beer."); | |
Js.log("Go to the store and buy some more, 99 bottles of beer on the wall."); | |
} : { | |
let wall = bottles(current); | |
let next = bottles(current - 1); | |
Js.log({j|$wall on the wall, $wall.|j}); | |
Js.log({j|Take one down and pass it around, $next on the wall.|j}); | |
Js.log(""); | |
countdownFrom(current - 1); | |
} | |
countdownFrom(99); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment