Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

object matching with multislots

2009-05-03
2012-11-23
  • Jack  Widman
    Jack Widman
    2009-05-03

    (defclass Man (is-a USER)
      (multislot friends))

    (defrule rule1
       (object (is-a Man) (friends ?f))
       =>
       (printout t "We have a friend." crlf))

    (make-instance jack of Man (friends create$ pete))  matches

    BUT

    (make-instance jack of Man (friends create$ pete sue)) does NOT match

    What am I doing wrong?

     
    • Gary Riley
      Gary Riley
      2009-05-03

      Your pattern matches a Man having exactly one friend. You want to use either (friends ?f $?) or (friends ? $?) and your make-instance call can be simplified to (make-instance jack of Man (friends pete sue)).

       
    • Jack  Widman
      Jack Widman
      2009-05-04

      Thanks Gary I really appreciate how you take time to answer questions. I think clips is fantastic.