Language prolog
(iso, using DCG)
Date: | 04/28/11 |
Author: | none |
URL: | n/a |
Comments: | 0 |
Info: | n/a |
Score: | (2.91 in 11 votes) |
% 99 bottles of beer song implemented in Prolog kiom(N,_) --> {N > 0, number_chars(N,A)}, A. kiom(0,I) --> {I =:= 1}, ['No more'] ; ['no more']. suff(N) --> {N =\= 1}, ['s'] ; [ ]. beer(N,X) --> kiom(N,X), [' bottle'], suff(N), [' of beer']. wall(N,X) --> beer(N,X), [' on the wall']. take(N) --> {N > 0}, ['Take one down and pass it around' ]. take(0) --> ['Go to the store and buy some more']. koplo(N) --> wall(N,1), [', '], beer(N,2), ['.\n'], {M is (N-1) mod 100}, take(N ), [', '], wall(M,2), ['.\n']. kanto(N) :- koplo(N,X,[]), findall(_,(member(E,X),print(E)),_), ( N =:= 0 ; M is N-1, nl, kanto(M) ), !.
Download Source | Write Comment
Alternative Versions
Version | Author | Date | Comments | Rate |
---|---|---|---|---|
Tweaked Remkos version | M@ | 11/28/05 | 2 | |
ISO Prolog w/ red cuts | Brent Spillner | 04/12/06 | 1 |
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments