How to get a list of objects in Prolog -
i resolving prolog exercises when fond myself difficulties resolving following one: consider have fact base object:
object(obj1). object(obj2). object(obj3). object(obj4). object(obj5). material(obj1,wood). material(obj2,wood). material(obj3, glass). material(obj4, glass). material(obj5, iron). type(obj1, able). type(obj2, chair). type(obj3, mesa). type(obj4, jar). type(obj5, rattle). weight(obj1, 10.5). weight(obj2, 1.5). weight(obj3, 1.6). weight(obj4, 0.5). weight(obj5, 1.8).
now idea make predicate object_description(list) list joining of each object it's caracteristics, like:
([obj1-wood-table-10.5, obj2-wood-chair-1.5, …, obj5-iron-rattle-1.8] )
i tried using bagof , findall couldn't find right answer.
thx in advance
?- findall(o-m-t-w,(object(o),material(o,m),type(o,t),weight(o,w)),res). res = [obj1-wood-able-10.5, obj2-wood-chair-1.5, obj3-glass-mesa-1.6, obj4-glass-jar-0.5, obj5-iron-rattle-1.8].
Comments
Post a Comment