package examples.beer; import static util.arithmetics.primitives.intUtil.*; /** *

* 99 bottles of beer, K.U.Leuven JCHR version. * tested in version 1.5.1 of the * K.U.Leuven JCHR System *

*

* Ported from the CHR(Prolog) version written by Jon Sneyers. *

* * @author Peter Van Weert */ public handler beer { public constraint main; private constraint beer(int), bottle, sing, capital, bottles, ofbeer, onwall, comma, take_one, dotnl, bottle_count, bottles1(int), writeresult; private constraint write(String), nl; rules { // make 99 bottles and start singing main <=> beer(99), sing. // make N bottles makebottle @ beer(N) <=> N > 0 | bottle, beer(dec(N)). endloop @ beer(_) <=> true.