関数を使って友達のリストを取得したいです。
(deffunction get-freinds-list (?age)
(bind ?facts (find-all-facts ((?f userdata))
(and (eq ?f:name userdata)
(>= ?f:age ?age))))
return ?facts)
(defrule getfriends
(wantlist yes)
=>
(printout t "under what age you want list for?" crlf)
(bind ?age (read))
(printout t "list is=" (get-freinds-list ?age ) crlf))
(defrule main-control
(initial-fact)
=>
(assert(wantlist yes))
)
(deffacts userfact
(userdata(name "pranay" )(likes tea cricket badminton table farewell)(age 12)(location pakistan)(employer Oracle))
(userdata(name "rohan" )(likes lunch kabaddi tt khoko farewell)(age 10)(location china)(employer TCS))
(userdata(name "srinath" )(likes dinner kabaddi cricket farewell)(age 15)(location china)(employer TCS))
(userdata(name "prateek" )(likes dinner kabaddi cricket farewell drinks)(age 15)(location china)(employer TCS))
(userdata(name "sachin" )(likes drinks kabaddi cricket)(age 15)(location china)(employer TCS))
)
(deftemplate userdata "Knoweledge base"
(slot name)
(multislot likes)
(slot age)
(slot location)
(slot employer)
)