99 Bottles of Beer/Prolog: Difference between revisions
m
Fixed syntax highlighting and duplicate headers.
m (Fixed syntax highlighting and duplicate headers.) |
|||
Line 4:
{{collection|99 Bottles of Beer}}
[[99 Bottles of Beer]] done in Prolog-languages
__toc__
==
{{works with|SWI Prolog}}
<
bottles(X):-
writef('%t bottles of beer on the wall \n',[X]),
Line 21 ⟶ 18:
bottles(XN).
:- bottles(99).</
It is possible to extend the previous version so to handle singular and plurals of the word 'bottle':
<
bottles(B) :-
dif(B,0), NewB is B - 1,
Line 40 ⟶ 37:
bottles(NewB).
:- bottles(99).</
Another version that handles plural/not plural conditions.
<
line2(0):- write('no more bottles of beer').
line2(1):- write('1 bottle of beer').
Line 62 ⟶ 59:
bottles(XN).
:- bottles(99).</
==
<
implement main
open core, std, console
Line 89 ⟶ 86:
goal
mainExe::run(main::run).</syntaxhighlight>
|