Skip to content

Instantly share code, notes, and snippets.

@greggirwin
Created April 24, 2017 19:33
Show Gist options
  • Save greggirwin/77b94dba0b4191c86c03426c71a4dee5 to your computer and use it in GitHub Desktop.
Save greggirwin/77b94dba0b4191c86c03426c71a4dee5 to your computer and use it in GitHub Desktop.
99 Bottles of Beer
bottles: func [n][
switch/default n [
0 ["no more bottles"]
1 ["1 bottle"]
][form reduce [n "bottles"]]
]
verse: func [n][
either n = 0 [
{No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.}
][
form reduce [
bottles n "of beer on the wall," bottles n "of beer.^/"
"Take one down and pass it around," bottles (n - 1) "of beer on the wall.^/"
]
]
]
repeat i 100 [print verse 100 - i]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment