Prolog

SWI Prolog
The Prolog Development Tool – A Prolog IDE for Eclipse

A quick prolog howto
FIRST STEPS IN PROLOG
SWI-Prolog owl logoHelp: I want the whole answer

Why is SWI-Prolog only giving one solution?
Prolog return results
Incomplete to difference lists
SWI-Prolog – show long list

FAQ

Question

location(desk, office).
location(apple, kitchen).
location(flashlight, desk).
location('washing machine', cellar).
location(nani, 'washing machine').
location(broccoli, kitchen).
location(crackers, kitchen).
location(computer, office).

list_things(Place) :-
	location(X, Place),
	tab(2),
	write(X),
	nl,
	fail.
list_things(AnyPlace).
Warning: c:/users/andreasb/workspace/prolog/myadven.pl:46:
	Singleton variables: [AnyPlace]

Answer

Singleton variable checking
Warning: (File:Line): Singleton variables: […]

list_things(Place) :-
	location(X, Place),
	tab(2),
	write(X),
	nl,
	fail.
list_things(_).
...

Leave a Reply

Your email address will not be published. Required fields are marked *