Skip to content

Instantly share code, notes, and snippets.

@wspringer
Created March 4, 2020 15:31
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 wspringer/d5fabacc21b48ab3d3ccaa8f92d635fb to your computer and use it in GitHub Desktop.
Save wspringer/d5fabacc21b48ab3d3ccaa8f92d635fb to your computer and use it in GitHub Desktop.
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