/* Balanced meal in Picat. From the menu.p2 program in Prolog-II+. Cf light_meal.pi This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ main => go. go ?=> balanced_meal(E,P,D,V), println([E,P,D,cal=V]), fail, nl. go => true. % " the menu " % index(-) hors_d_oeuvre(artichauts_melanie). hors_d_oeuvre(truffes_sous_le_sel). hors_d_oeuvre(cresson_oeuf_poche). % index(-) meat(grillade_de_boeuf). meat(poulet_au_tilleul). % index(-) fish(bar_aux_algues). fish(chapon_farci). % index(-) dessert(sorbet_aux_poires). dessert(fraises_chantilly). dessert(melon_en_surprise). % " main-course " main_course(P) ?=> meat(P). main_course(P) => fish(P). % " composition of a meal " meal(E,P,D) => hors_d_oeuvre(E), main_course(P), dessert(D). % " calorific value of a portion" % index(-,-) calories(artichauts_Melanie,150). calories(cresson_oeuf_poche,202). calories(truffes_sous_le_sel,212). calories(grillade_de_boeuf,532). calories(poulet_au_tilleul,400). calories(bar_aux_algues,292). calories(chapon_farci,254). calories(sorbet_aux_poires,223). calories(fraises_chantilly,289). calories(melon_en_surprise,122). % " calorific value of a meal " value(E,P,D,V) => calories(E,X), calories(P,Y), calories(D,Z), V = X + Y + Z. % " balanced meal " balanced_meal(E,P,D,V) => meal(E,P,D), value(E,P,D,V), V < 800.