|
Revision 4601, 0.8 KB
(checked in by pmoura, 7 weeks ago)
|
|
Added svn:mime-type property to source files (set to text/x-logtalk).
|
-
Property svn:mime-type set to
text/x-logtalk
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | /******************************************************* |
|---|
| 2 | * 99 Bottles of Beer |
|---|
| 3 | * Paulo Moura - January 21, 2007 |
|---|
| 4 | * bottles.lgt |
|---|
| 5 | * To execute start Logtalk and use the query |
|---|
| 6 | * logtalk_load(bottles). |
|---|
| 7 | *******************************************************/ |
|---|
| 8 | |
|---|
| 9 | :- object(bottles). |
|---|
| 10 | |
|---|
| 11 | :- initialization(sing(99)). |
|---|
| 12 | |
|---|
| 13 | sing(0) :- |
|---|
| 14 | write('No more bottles of beer on the wall, no more bottles of beer.'), nl, |
|---|
| 15 | write('Go to the store and buy some more, 99 bottles of beer on the wall.'), nl, nl. |
|---|
| 16 | sing(N) :- |
|---|
| 17 | N > 0, |
|---|
| 18 | N2 is N -1, |
|---|
| 19 | beers(N), write(' of beer on the wall, '), beers(N), write(' of beer.'), nl, |
|---|
| 20 | write('Take one down and pass it around, '), beers(N2), write(' of beer on the wall.'), nl, nl, |
|---|
| 21 | sing(N2). |
|---|
| 22 | |
|---|
| 23 | beers(0) :- |
|---|
| 24 | write('no more bottles'). |
|---|
| 25 | beers(1) :- |
|---|
| 26 | write('1 bottle'). |
|---|
| 27 | beers(N) :- |
|---|
| 28 | N > 1, |
|---|
| 29 | write(N), write(' bottles'). |
|---|
| 30 | |
|---|
| 31 | :- end_object. |
|---|