| 1 |
:- object(bottles). |
| 2 |
|
| 3 |
:- initialization(sing(99)). |
| 4 |
|
| 5 |
sing(0) :- |
| 6 |
write('No more bottles of beer on the wall, no more bottles of beer.'), nl, |
| 7 |
write('Go to the store and buy some more, 99 bottles of beer on the wall.'), nl, nl. |
| 8 |
sing(N) :- |
| 9 |
N > 0, |
| 10 |
N2 is N - 1, |
| 11 |
beers(N), write(' of beer on the wall, '), beers(N), write(' of beer.'), nl, |
| 12 |
write('Take one down and pass it around, '), beers(N2), write(' of beer on the wall.'), nl, nl, |
| 13 |
sing(N2). |
| 14 |
|
| 15 |
beers(0) :- |
| 16 |
write('no more bottles'). |
| 17 |
beers(1) :- |
| 18 |
write('1 bottle'). |
| 19 |
beers(N) :- |
| 20 |
N > 1, |
| 21 |
write(N), write(' bottles'). |
| 22 |
|
| 23 |
:- end_object. |