Name:
Anonymous
2008-02-02 18:45
% -*-Prolog-*-
% BD directa de nacionalidades para *
color(english, red).
animal(swede, dog).
drink(danish, tea).
number(norwegian, 1).
cigar(german, prince).
% Relacoes com 1 grau
color(N, green) :- drink(N, coffee).
cigar(N, pallmall) :- animal(N, bird).
color(N, yellow) :- cigar(N, dunhill).
number(N, 3) :- drink(N, milk).
drink(N, beer) :- cigar(N, bluemasters).
color(N, green) :- number(N, X), color(N2, white), number(X2, X+1).
cigar(N, blends) :- number(N, X), animal(N2, cat), number(X2, X+1);
number(N, X), animal(N2, cat), number(X2, X-1).
animal(N, horse) :- number(N, X), cigar(N2, dunhill), number(X2, X+1);
number(N, X), cigar(N2, dunhill), number(X2, X-1).
number(N, X) :- color(N2, blue), number(N2, X+1);
color(N2, blue), number(N2, X-1).
cigar(N, blends) :- number(N, X), drink(N2, water), number(N2, X+1);
number(N, X), drink(N2, water), number(N2, X-1).
$ swipl
%...
$- [einstein].
% ... Some stupid warnings...
Yes
$- animal(N, fish).
No
$-
Me fail Prolog? That's unpossible.
Why?
Name:
Anonymous
2008-02-02 19:16
Hey, I think you could do that in Haskell with a list of nomads or something.
Name:
Anonymous
2008-02-02 19:50
Updated code, now with loops that must GTFO.
% -*-Prolog-*-
color(english, red).
animal(swede, dog).
drink(danish, tea).
number(norwegian, 1).
cigar(german, prince).
color(N, green) :- drink(N, coffee).
cigar(N, pallmall) :- animal(N, bird).
color(N, yellow) :- cigar(N, dunhill).
number(N, 3) :- drink(N, milk).
drink(N, beer) :- cigar(N, bluemasters).
color(N, green) :- number(N, X), NX is X+1, NX < 6, color(N2, white), number(N2, NX).
cigar(N, blends) :- number(N, X), NX is X+1, NX < 6, animal(N2, cat), number(N2, NX);
number(N, X), NX is X-1, NX > 0, animal(N2, cat), number(N2, NX).
animal(N, horse) :- number(N, X), NX is X+1, NX < 6, cigar(N2, dunhill), number(N2, NX);
number(N, X), NX is X-1, NX > 0, cigar(N2, dunhill), number(N2, NX).
number(_, X) :- NX is X+1, NX < 6, color(N2, blue), number(N2, NX);
NX is X-1, NX > 0, color(N2, blue), number(N2, NX).
cigar(N, blends) :- number(N, X), NX is X+1, NX < 6, drink(N2, water), number(N2, NX);
number(N, X), NX is X-1, NX > 0, drink(N2, water), X > 1, number(N2, NX).
% loops. to GTFO
color(N, _) :- animal(N, _).
color(N, _) :- drink(N, _).
color(N, _) :- number(N, _).
color(N, _) :- cigar(N, _).
animal(N, _) :- color(N, _).
animal(N, _) :- drink(N, _).
animal(N, _) :- number(N, _).
animal(N, _) :- cigar(N, _).
drink(N, _) :- color(N, _).
drink(N, _) :- animal(N, _).
drink(N, _) :- number(N, _).
drink(N, _) :- cigar(N, _).
number(N, _) :- color(N, _).
number(N, _) :- animal(N, _).
number(N, _) :- drink(N, _).
number(N, _) :- cigar(N, _).
cigar(N, _) :- color(N, _).
cigar(N, _) :- animal(N, _).
cigar(N, _) :- drink(N, _).
cigar(N, _) :- number(N, _).
Name:
Anonymous
2009-07-12 6:22
about or I something boss for or