beer.fun 642 B

123456789101112131415161718192021222324252627
  1. # compile with --show to display the lyrics
  2. #import nat
  3. # each function takes a natural number to a block of text
  4. quantity = # forms the plural as needed
  5. ~&iNC+ --' of beer'+ ~&?(
  6. 1?=/'1 bottle'! --' bottles'+ ~&h+ %nP,
  7. 'no more bottles'!)
  8. verse =
  9. ^(successor,~&); ("s","n"). -[
  10. -[quantity "s"]- on the wall, -[quantity "s"]-,
  11. Take one down and pass it around, -[quantity "n"]- on the wall.]-
  12. refrain "n" =
  13. -[
  14. No more bottles of beer on the wall, -[quantity 0]-.
  15. Go to the store and buy some more, -[quantity "n"]- on the wall.]-
  16. whole_song "n" = ~&ittt2BSSL (verse*x iota "n")--<refrain "n">
  17. main = whole_song 99