Jump to content


Using a rule to output complete info from a fact


2 replies to this topic

#1 joeyea

    New Member

  • Members
  • Pip
  • 1 posts

Posted 09 November 2010 - 01:14 PM

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 alphadog

    DevMaster Staff

  • Moderators
  • 1716 posts

Posted 09 November 2010 - 02:17 PM

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...torial/2_7.html
Hyperbole is, like, the absolute best, most wonderful thing ever! However, you'd be an idiot to not think dogmatism is always bad.

#3 Reedbeta

    DevMaster Staff

  • Administrators
  • 5311 posts
  • LocationSanta Clara, CA

Posted 09 November 2010 - 05:30 PM

This is not gamedev related, so I'm closing this thread.
reedbeta.com - developer blog, OpenGL demos, and other projects





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users