Yuce's Blog

Cognitive dissonance is yoga for the brain.*

99 Bottles of Beer in Marvin3

2005-09-29

How to write 99 bottles of beer in Marvin3?

:bottles  dup dup 1 > [" bottles"] [" bottle"] ifte cat ;

:sing
    bottles dup " of beer on the wall," cat println
    " of beer. " cat println
    "Take one down, pass it around." println ;

:theend  "No more beer left." println ;

:beers  [dup 0 >] [sing decr] while theend eat ;

# start singing
99 beers

Also you may check a previous post for the original Marvin. Other languages? 99 Bottles of Beer on the Wall lists many. See 99 Bottles of Beer on Wikipedia.

marvin3, marvin, 99 bottles

comments powered by Disqus