t99bott.nim 866 B

123456789101112131415161718192021222324252627282930313233
  1. discard """
  2. errormsg: "cannot evaluate at compile time: bn"
  3. file: "t99bott.nim"
  4. line: 26
  5. """
  6. ## 99 Bottles of Beer
  7. ## http://www.99-bottles-of-beer.net/
  8. ## Nim version
  9. ## Author: Philippe Lhoste <PhiLho(a)GMX.net> http://Phi.Lho.free.fr
  10. # 2012-11-25
  11. # Loosely based on my old Lua version... Updated to current official lyrics.
  12. proc GetBottleNumber(n: int): string =
  13. var bs: string
  14. if n == 0:
  15. bs = "No more bottles"
  16. elif n == 1:
  17. bs = "1 bottle"
  18. else:
  19. bs = $n & " bottles"
  20. return bs & " of beer"
  21. for bn in countdown(99, 1):
  22. const cur = GetBottleNumber(bn)
  23. echo(cur, " on the wall, ", cur, ".")
  24. echo("Take one down and pass it around, ", GetBottleNumber(bn-1),
  25. " on the wall.\n")
  26. echo "No more bottles of beer on the wall, no more bottles of beer."
  27. echo "Go to the store and buy some more, 99 bottles of beer on the wall."