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.
Post Reply
ProximaC
Posts: 1
Joined: Mon Dec 09, 2013 8:11 am

CLISP Programming

Post by 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.

DONE!!

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

JamesF
Posts: 98
Joined: Thu Jul 10, 2008 7:14 pm

Re: CLISP Programming

Post by 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..?

cat20
Posts: 1
Joined: Wed Sep 17, 2014 2:54 am

CLISP Programming

Post by cat20 » Wed Sep 17, 2014 2:56 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.
Naeem

Goheeca
Posts: 271
Joined: Thu May 10, 2012 12:54 pm
Contact:

Re: CLISP Programming

Post by Goheeca » Mon Sep 22, 2014 1:06 am

Actually you mean CLIPS (A Tool for Building Expert Systems) and not CLISP (an ANSI Common Lisp Implementation). I found the documentation, you can reference slots (I can't find better example so don't bother with the topic of that particular section) or look at this example (section Phases and Control Facts). I guess that almost nobody knows CLIPS here so the help will be limited.
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.

Post Reply