Re: I just don't get it (list)
- From: Matthew Huntbach <mmh@xxxxxxxxxxxxxx>
- Date: Thu, 8 Jun 2006 14:33:29 +0100
On Wed, 7 Jun 2006, manny wrote:
i'm new to prolog, and so far it's been easy, but now came lists... and i
don't get them.
here's the deal:
for exercising i'm working with the old "family tree" problem.
Here's what I have to do:
add_person(Name,Gender) - is used to add a certain person, dependant on the
gender into the list.
the list needs to be defined in:
person_list(Name,Gender), where Name is of course a list of names [johnny,
john, andsoon]
when you add a new person, the listener has to print out the name just
added, and below that, the complete list with all the names (if any) added
into the list before that.
Can anyone help me? I keep looking into manuals & stuff and just don't get
it :). But there must be some little "thing" which keeps me from *getting*
it :), there must be :)
From what you have written I feel it would be impossible for someonewho isn't already familiar with the problem you are working on to
understand what you require. For example, what is "the list"? Who are
what is "the listener"? What do you mean by "add" (bearing in mind that
Prolog has NO destructive data values)? What do you mean by "print"?
What relationship does the variable Gender have with the variable Name
in a call of one of your predicates? What do you mean by "all the names added"?
The first step to good programming in any language is to define precisely just what it is you want your methods/procedures/predicates to do. Try that first, and then come back. You may find doing it is enough to move you forward to a solution.
Matthew Huntbach
.
- Follow-Ups:
- Re: I just don't get it (list)
- From: manny
- Re: I just don't get it (list)
- References:
- I just don't get it (list)
- From: manny
- I just don't get it (list)
- Prev by Date: Re: Matrices implementations
- Next by Date: Re: I just don't get it (list)
- Previous by thread: I just don't get it (list)
- Next by thread: Re: I just don't get it (list)
- Index(es):