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

99 Bottles of Beer on the Wall

2005-04-16

The following is one of the ways to do 99 bottles of beer in Marvin. If you don't know what I mean, check 99 Bottles of Beer on the Wall.

99 ^beers
{
%beers 0 >
iftrue
    " bottle(s) of beer" & dup " on the wall," & println
    "." & println
    "Take one down, pass it around," println
    %beers -- ^beers
    repeat
}

"No more beers left." println

marvin, 99 bottles