Using a rule to output complete info from a fact

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]):-

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.

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:\~jrfisher/www/prolog_tutorial/2_7.html

Reedbeta 167 Nov 09, 2010 at 17:30

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