Using a rule to output complete info from a fact

F4340e115993c9b7ea1ee9a44a577ac7
0
joeyea 101 Nov 09, 2010 at 13:14

Hiya, I know this may be a very simple question but i’m just starting prolog and trying to get a grasp on it - just struggling a bit.

What I am trying to do, is use a rule such as : which_system(Component).

That will return the info on a system that is declared in a fact liek
spec([execomp211, hard_disk(40), ram(ram500MB), processor(intel_core2_duo)]).

So if i entered : which_system(hard_disk(120)). into the console then it would return the info about that system.

I’ve been told to use the methods:

member1(X, [X Y]).

member1(X, [Z|Y]):-
member1(X,Y).

But I can’t seem to find anymore help than that online! I’m not asking to do this for me, jsut any pointers would bemuch appreciated

Thanks :)

2 Replies

Please log in or register to post a reply.

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 Nov 09, 2010 at 14:17

Ah, yes, as we get closer to the end of a semester, the homework gets tougher… :)

You need to get familiar with Prolog lists, ex:

http://www.csupomona.edu/\~jrfisher/www/prolog_tutorial/2_7.html

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 168 Nov 09, 2010 at 17:30

This is not gamedev related, so I’m closing this thread.