Hi,
Sorry that if my questions are too ...; I'm a beginner at Jess, but I've
this question on my mind, and I can't figure it out neither from the Jess
manual nor from the examples in the Jess folder (by the way, does anyone
know a simpler example source), that if we want to "recall" a slot under
some template, in a rule and perform a task on (concatonate, add, subtract,
etc.) it, how should we do it? For example if we're to write a program in
Jess that inputs the testmarks of a student, then somehow adds them up and
prints out that if he/she has passed/failed, how should it be written; I'm
pretty sure it's not be the way below:
;;----------------------------------------------------------
(deftemplate Mark
(slot mark1)
(slot mark2)
(slot mark3)
(slot mark4)
(slot mark5))
;;we can't add another slot here which performs addition,
;;like (slot totmarks&:(+ mark1 mark2 mark3 mark4 mark5)), could we?
(defrule input-marks
=>
(printout t "What is your 1st test's mark? (out of 20) ")
(assert (Mark (mark1 (read))))
(printout t "What is your 2nd test's mark? (out of 20) ")
(assert (Mark (mark2 (read))))
(printout t "What is your 3rd test's mark? (out of 20) ")
(assert (Mark (mark3 (read))))
(printout t "What is your 4th test's mark? (out of 20) ")
(assert (Mark (mark4 (read))))
(printout t "What is your 5th test's mark? (out of 20) ")
(assert (Mark (mark5 (read)))))
(defrule pass
((+ (Mark (mark1)) (Mark (mark2)) (Mark (mark3)) (Mark (mark4)) (Mark
(mark5)))>= 50)
=>
(printout t "congrats, you've passed this course" crlf))
(defrule fail
((+ (Mark (mark1)) (Mark (mark2)) (Mark (mark3)) (Mark (mark4)) (Mark
(mark5)))<= 50)
=>
(printout t "sorry, you've failed the course" crlf))
(reset)
(run)
;;----------------------------------------------------------