CLISP Programming

You have problems, and we're glad to hear them. Explain the problem, what you have tried, and where you got stuck.
Feel free to share a little info on yourself and the course.
Forum rules
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.

CLISP Programming

Postby ProximaC » Mon Dec 09, 2013 8:24 am

There are two parts of this question and I've managed to do the first part. It's the second part I'm currently having problem with.

1. Create a factbase of students and their CGPA for at least 5 students with CGPA ranging from 2 to 5 with students having the CGPA (4.1) by defining deftemplate facts. The name slot should be STRING type and CGPA slot should be of floating point number.


But how to...

2. Write a rule to find names and their CGPA and display the result on the monitor.

(deffacts students-list

(student (name “A B C”) (CGPA 2.0))

(student (name “D E F”) (CGPA 2.5))

(student (name “G H I”) (CGPA 3.0))

(student (name “J K L”) (CGPA 4.1))

(student (name “M N O”) (CGPA 4.1)))
Posts: 1
Joined: Mon Dec 09, 2013 8:11 am

Re: CLISP Programming

Postby JamesF » Tue Dec 10, 2013 7:15 am

So, what you need to do is iterate over the factbase and, for each entry in it, extract two elements, and then incorporate those two elements into text output that you send to the screen.

For the second bit, look into print and format; the latter is particularly good for this kind of thing.

For iterating over the factbase, you need to know what kind of collection you've stored the facts in, and how to iterate over it. Is it a list, a hashmap, a vector, or something else?
For extracting the elements, that depends entirely on what kind of a thing you've stored them in. Again, are you using lists, hashmaps, objects, structs..?
Posts: 95
Joined: Thu Jul 10, 2008 7:14 pm

Return to Homework

Who is online

Users browsing this forum: No registered users and 2 guests