retroforth/example/99Bottles.forth
crc e549b4ced6 no longer use ```` for code blocks; this fence sequence will be used for embedded tests in a later update
FossilOrigin-Name: dfed0de00b8d63672a882b79c4951cce0076007ef208c063b2f4e54fe9bd08f8
2018-04-25 16:57:28 +00:00

35 lines
578 B
Forth

# example|99Bottles
Display the text for the *99 Bottles of Beer* song.
~~~
[ dup putn sp 'bottles puts ]
[ '1_bottle puts ]
[ 'no_more_bottles puts ]
'bottles d:create
, , ,
:display-bottles
dup #2 n:min bottles + fetch call ;
:display-beer
display-bottles '_of_beer puts ;
:display-wall
display-beer '_on_the_wall puts ;
:display-take
'Take_one_down,_pass_it_around puts ;
:display-verse
display-wall nl display-beer nl
n:dec display-take nl display-wall nl ;
:?dup
dup 0; ;
:verses
[ nl display-verse dup n:-zero? ] while drop ;
#99 verses
~~~