Subject: RE: [SWIPL] I need help about my code

From: "Danny Wages" <[email-masked]>
Date: Mon, 26 Mar 2001 14:54:20 -0700

Simply remove the repeat and add a P(_N) clause.

Danny Wages :- Avaya Communication, 303-538-3972, [email-masked]
<mailto:[email-masked]>

-----Original Message-----
From: Ryo Saeba [mailto:[email-masked]]
Sent: Monday, March 26, 2001 2:25 PM
To: [email-masked]
Subject: [SWIPL] I need help about my code

Hi! there:

course_name(cs5373, 'Database Systems').
course_name(cs5393, 'Automata Theory').
course_name(cs5463, 'Computer Networks').
course_name(cs5483, 'Artificial Intelligence').
course_name(cs5493, 'Computer Graphics I').
course_name(cs5503, 'Computer Graphics II').
course_name(cs5523, 'Software Engineering I').
course_name(cs5533, 'Software Engineering II').
course_name(cs5583, 'UNIX Systems Programming').
course_name(cs5703, 'Analysis of Algorithms').
course_name(cs5793, 'Compilers').
course_name(cs5903, 'Distributed Computing').
course_name(cs6483, 'Advanced Artificial Intelligence').
course_name(cs6493, 'Robotic Software Control').
course_name(cs6603, 'Computer Performance Evaluation').
course_name(cs6623, 'Data Security').
course_name(cs6673, 'Natural Language Processing').
course_name(cs6703, 'Advanced Analysis of Algorithms').
course_name(cs6783, 'Computability Theory').
course_name(cs6833, 'Parallel Processing').

person_course(danid, 1999, fall, cs5523).
person_course(danid, 2000, spring, cs5393).
person_course(danid, 2000, spring, cs5533).
person_course(danid, 2000, fall, cs5493).
person_course(danid, 2000, fall, cs5703).
person_course(danid, 2001, spring, cs5463).
person_course(danid, 2001, spring, cs5503).
person_course(danid, 2001, spring, cs6673).
person_course(danid, 2001, spring, cs6703).

  I wrote a program about Database. I tried to list all of
the courses that danid has taken, if I use

p(N) :-
        repeat,
        person_course(N, _, _, C),
        course_name(C, CT),
        display(C), put(32), display(CT), nl,
        fail.

after I consult this program and I wrote
?- p(danid).

The screen will repeat to list all course danid has taken
again and again.

If I use

p(N) :-
        person_course(N, _, _, C),
        course_name(C, CT),
        display(C), put(32), display(CT), nl.

then computer only give me the first course danid has taken.

Does anybody know how can I fixed my problem
Thanks!

_______________________________________________________
Send a cool gift with your E-Card
http://www.bluemountain.com/giftcenter/

----------------
* To UNSUBSCRIBE, please use the HTML form at

    http://www.swi.psy.uva.nl/projects/SWI-Prolog/index.html#mailinglist

or send mail to [email-masked] using the Subject:
"unsubscribe"
(without the quotes) and *no* message body.

** An ARCHIVE of this list is maintained at

    http://www.swi.psy.uva.nl/projects/SWI-Prolog/mailinglist/archive/