2017-10-16 18:09:39 +02:00
|
|
|
# example|99Bottles
|
|
|
|
|
|
|
|
Display the text for the *99 Bottles of Beer* song.
|
|
|
|
|
|
|
|
Declare module constant (prevents reloading when using `import`):
|
|
|
|
|
|
|
|
````
|
|
|
|
:example|99Bottles ;
|
|
|
|
````
|
|
|
|
|
|
|
|
````
|
|
|
|
[ dup putn sp 'bottles puts ]
|
|
|
|
[ '1_bottle puts ]
|
|
|
|
[ 'no_more_bottles puts ]
|
|
|
|
'bottles d:create
|
|
|
|
, , ,
|
|
|
|
|
2017-10-20 03:57:27 +02:00
|
|
|
:display-bottles
|
2017-10-16 18:09:39 +02:00
|
|
|
dup #2 n:min bottles + fetch call ;
|
|
|
|
|
2017-10-20 03:57:27 +02:00
|
|
|
:display-beer
|
|
|
|
display-bottles '_of_beer puts ;
|
2017-10-16 18:09:39 +02:00
|
|
|
|
2017-10-20 03:57:27 +02:00
|
|
|
:display-wall
|
|
|
|
display-beer '_on_the_wall puts ;
|
2017-10-16 18:09:39 +02:00
|
|
|
|
2017-10-20 03:57:27 +02:00
|
|
|
:display-take
|
|
|
|
'Take_one_down,_pass_it_around puts ;
|
2017-10-16 18:09:39 +02:00
|
|
|
|
2017-10-20 03:57:27 +02:00
|
|
|
:display-verse
|
|
|
|
display-wall nl display-beer nl
|
|
|
|
n:dec display-take nl display-wall nl ;
|
2017-10-16 18:09:39 +02:00
|
|
|
|
|
|
|
:?dup
|
|
|
|
dup 0; ;
|
|
|
|
|
|
|
|
:verses
|
2017-10-20 03:57:27 +02:00
|
|
|
[ nl display-verse dup n:-zero? ] while drop ;
|
2017-10-16 18:09:39 +02:00
|
|
|
|
|
|
|
#99 verses
|
|
|
|
````
|