Клипы: печатать значение слота из шаблона фактов?
Мы должны просмотреть список людей и распечатать "имя имеет голубые глаза", если у человека в списке голубые глаза. Мы заставили его напечатать 3 раза, так как у 3 человек в списке есть голубые глаза, но мы не можем понять, как получить доступ к слоту имени первого факта.
Вот код на данный момент:
(deftemplate person (slot first-name) (slot eye-color)(slot hair-color)
(slot hgt) (slot wgt)
)
(deffacts some-people "people involved"
(person (first-name kevin) (eye-color blue) (hgt 175) (wgt 93))
(person (first-name john) (eye-color brown) (hgt 190) (wgt 80))
(person (first-name smith) (eye-color hazel) (hgt 165) (wgt 75))
(person (first-name tom) (eye-color brown) (hgt 172) (wgt 77))
(person (first-name alan) (eye-color blue) (hgt 190) (wgt 83))
(person (first-name patricia) (eye-color blue) (hgt 175) (wgt 55))
(person (first-name Leena) (eye-color brown) (hgt 176) (wgt 60))
(person (first-name michael) (eye-color hazel) (hgt 190) (wgt 88))
(person (first-name robert) (eye-color grey) (hgt 170) (wgt 77))
(person (first-name judy) (eye-color hazel) (hgt 170) (wgt 76))
)
(defrule blueEyes "Print people with blue eyes"
(person (eye-color blue))
=>
(printout t ??whatgoeshere?? " has-blue-eyes" crlf))
Любая помощь приветствуется. Спасибо!
1 ответ
(defrule blueEyes "Print people with blue eyes"
(person (first-name ?name) (eye-color blue))
=>
(printout t ?name " has blue eyes" crlf))