Skip to content

Instantly share code, notes, and snippets.

@cmontella
Created December 14, 2016 18:40
Show Gist options
  • Save cmontella/858158f17056232797a870f7abacf31c to your computer and use it in GitHub Desktop.
Save cmontella/858158f17056232797a870f7abacf31c to your computer and use it in GitHub Desktop.

99 Bottles of Beer

http://www.99-bottles-of-beer.net/lyrics.html

search
    n = range[from: 99, to: 0, increment: -1]
    sn = sort[given: n, direction: "down"]
  (pos1, pos2, pos3)
    = if n = 2 then ( "2 bottles", "2 bottles", "1 bottle")
            else if n = 1 then ( "1 bottle", "1 bottle", "no more bottles")
            else if n = 0 then ( "No more bottles", "no more bottles", "")
            else  ( "{{n}} bottles", "{{n}} bottles", "{{n - 1}} bottles")
  second-line
    = if n = 0 then "Go to the store and buy some more, 99 bottles of beer on the wall."
          else "Take one down and pass it around, {{pos3}} of beer on the wall."
   
bind @browser
    [#h3 sort: sn, text: "", n]
    [#div sort: sn, text: "{{pos1}} of beer on the wall, {{pos2}} of beer."]
    [#div sort: sn, text: second-line ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment