Page 1 of 1

CLISP Programming

PostPosted: Mon Dec 09, 2013 8:24 am
by ProximaC
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)))

Re: CLISP Programming

PostPosted: Tue Dec 10, 2013 7:15 am
by JamesF
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..?

CLISP Programming

PostPosted: Wed Sep 17, 2014 2:56 am
by cat20
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.

Re: CLISP Programming

PostPosted: Mon Sep 22, 2014 1:06 am
by Goheeca
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.