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)))
CLISP Programming
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.
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.
Re: CLISP Programming
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..?
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
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
Re: CLISP Programming
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.