5f5589e8de
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1175 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
100 lines
2.3 KiB
Plaintext
100 lines
2.3 KiB
Plaintext
=================================================================
|
|
Logtalk - Object oriented extension to Prolog
|
|
Release 2.21.6
|
|
|
|
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
|
|
=================================================================
|
|
|
|
|
|
% start by loading the example:
|
|
|
|
| ?- logtalk_load(loader).
|
|
...
|
|
|
|
|
|
% Harry Potter's room of potions logical puzzle:
|
|
|
|
| ?- potions::potions(P1, P2, P3, P4, P5, P6, P7).
|
|
|
|
P1 = poison
|
|
P2 = wine
|
|
P3 = forward
|
|
P4 = poison
|
|
P5 = poison
|
|
P6 = wine
|
|
P7 = backwards
|
|
|
|
yes
|
|
|
|
|
|
% Horse show logical puzzle:
|
|
|
|
| ?- horses::(horses(S), print(S)).
|
|
1 place: april riding doc, the chestnut gelding
|
|
2 place: sue riding danny, the bay gelding
|
|
3 place: doc riding gopher, the gray gelding
|
|
4 place: danny riding april, the white mare
|
|
5 place: gopher riding sue, the black mare
|
|
|
|
S = [h(doc,gelding,chestnut,april,1),h(danny,gelding,bay,sue,2),h(gopher,gelding,gray,doc,3),h(april,mare,white,danny,4),h(sue,mare,black,gopher,5)] ?
|
|
|
|
yes
|
|
|
|
|
|
% Who Stole the Jam?
|
|
|
|
| ?- jam_thief::thief(Thief).
|
|
|
|
Thief = hare
|
|
|
|
yes
|
|
|
|
| ?- jam_thief::thief(Thief, Why).
|
|
|
|
Thief = hare
|
|
Why = [trusty(dormouse),liar(hare),trusty(hatter)] ?
|
|
|
|
yes
|
|
|
|
|
|
% Houses logical puzzle:
|
|
|
|
| ?- houses::(houses(S), print(S)).
|
|
h(norwegian,fox,kool,water,yellow)
|
|
h(ukrainian,horse,chesterfield,tea,blue)
|
|
h(english,snake,winston,milk,red)
|
|
h(japonese,zebra,kent,coffee,green)
|
|
h(spanish,dog,lucky,juice,white)
|
|
|
|
S = [h(norwegian,fox,kool,water,yellow),h(ukrainian,horse,chesterfield,tea,blue),h(english,snake,winston,milk,red),h(japonese,zebra,kent,coffee,green),h(spanish,dog,lucky,juice,white)] ? ;
|
|
|
|
yes
|
|
|
|
|
|
% Passing a note logical puzzle
|
|
|
|
| ?- note::(students(S), print(S)).
|
|
s(mary,english,red,1)
|
|
s(paul,math,yellow,2)
|
|
s(josephine,science,green,3)
|
|
s(derrick,french,blue,4)
|
|
s(alexis,reading,black,5)
|
|
|
|
S = [s(mary,english,red,1),s(paul,math,yellow,2),s(josephine,science,green,3),s(derrick,french,blue,4),s(alexis,reading,black,5)] ?
|
|
|
|
yes
|
|
|
|
|
|
% Mort's Letter from Camp Swampy logical puzzle
|
|
|
|
| ?- camp_swampy::(beds(S), print(S)).
|
|
tim thomas, from maine, sleeps on bed number 1
|
|
sam franklin, from north_carolina, sleeps on bed number 2
|
|
mac miller, from virginia, sleeps on bed number 3
|
|
fred james, from florida, sleeps on bed number 4
|
|
john smith, from arkansas, sleeps on bed number 5
|
|
|
|
S = [b(tim,thomas,maine,1),b(sam,franklin,north_carolina,2),b(mac,miller,virginia,3),b(fred,james,florida,4),b(john,smith,arkansas,5)] ?
|
|
|
|
yes
|