thelizardreborn
Programmer
I am using prolog to act as a database. My facts are all of the structure relation(Name,Type,Weight), with weight being floats.
I want to write a rule and query to write all relations with a weight greater than an input weight to the screen. I can get it to write one, here is what I have so far.
relation(itemA,type1,1.0).
relation(itemB,type3,16.0).
relation(itemC,type2,23.0).
weighOver(Weight):-
relation(Name,_,X),X>Weight,write(Name).
I might add that I am a beginner to Prolog, as well as any other non-procedural language, so I am having to rework how I approach problems. If I have to scrap what I have so far and set things up a different way, that's ok.
Thanks in advance!
I want to write a rule and query to write all relations with a weight greater than an input weight to the screen. I can get it to write one, here is what I have so far.
relation(itemA,type1,1.0).
relation(itemB,type3,16.0).
relation(itemC,type2,23.0).
weighOver(Weight):-
relation(Name,_,X),X>Weight,write(Name).
I might add that I am a beginner to Prolog, as well as any other non-procedural language, so I am having to rework how I approach problems. If I have to scrap what I have so far and set things up a different way, that's ok.
Thanks in advance!