Search code examples
clips

Create rules in CLIPS and template person


Template Person

a. Define a template for person, contains full name, children names

b. Define a rule that prints the parents that have more than 3 children

c. Define a rule that print the parent of a certain child

The specified child name will be asserted in a fact called (child-name <name>)

i dont know how to check if the person have more than 3 children


Solution

  • If you have a parent deftemplate with a child-names multislot, then the following pattern will match any parent with more than 3 children:

    (parent (childs-names $?names&:(> (length$ ?names) 3)))