I hope some of you know Prolog.
CSC 240 : Intro do different programming languages.
Just introduced to prolog today. Assignment was to make a program with 10 facts and 3 rules. I've done that. So this isn't a do my home work question, its a curiosity--I want to be better question.
My question is:
How can I display all the associations (facts) known about a subject?
In the interaction i want to see:
I'm sure it has to do with a recursive call.
The car is big.
The car is yellow.
The car is ford.
I've also got a problem with "what_is(Property)". It will return only the first fact it finds that matches the property. However, I want it to display all the subjects that are Property.
Heres the stuff I've got so far:
% Author: Jeremy Giberson
% Date: 4/22/2004
%uncontestable facts, for associations.
%query the fact list to see if the Object is a Property.
%Object = car, box, animal, watch, etc.
%Property = big, small, blue, red, heavy, etc.
is_the(Object, Property) :- object_color(Object, Property);
%querry axioms list to dertermine what a property might be.
%Value is a property, not an object. Red, big, small, furry etc. NOT car, box, watch etc.
what_is_a(Value) :- axioms(color, Value), write(Value), write(' is a color.'), nl; % a color?
axioms(size, Value), write(Value), write(' is a size.'), nl; % a size?
%..... % insert more axiom tests here
write('it is unknown what '), write(Value), write(' is.'), nl. % unknown, not define axiom
%See if there is an Object in the list of facts, that has the attribute of Property, display that object if it exists.
what_is(Property) :- is_the(Object, Property), write('The '), write(Object), write(' is '), write(Property).
%See if there is an Object in the list of facts, that has ANY '_' attribute, display so if there is.
is_there_a(Object) :- is_the(Object, _), write('There is a '), write(Object).
Hopefully Thanks in Advance