Menu

How to match a symbol with a class name

Help
Palouxic
2011-06-02
2012-11-23
  • Palouxic

    Palouxic - 2011-06-02

    Hi there. I'm new in CLIPS and I'm so lost. This is what I0m trying to do:

    I have a group of classes that are subclass of a class named PeliculaSerie, which is subclass of Contingut. I also have a class named ValoracioGenere that contains a symbol with the name of one of the subclasses mentioned before and a symbol who can contain the value "gens".  I wanna erase all the subclasses which names match the symbol in Valoracio Genere. Right now I'm doing it using a slot in the subclasses which contains the name of the subclass:

    (defrule remove-edatR""
        ?user <- (object (is-a User) (grauGenere ?grauU)(nomGenere ?nomU));
        ?program <- (object (is-a Contingut) (nomGenere ?genereP))
        (test (and (eq ?grauU gens) (eq ?nomU ?genereP))
        =>
        (send ?program delete)
    )

    I would like to remove the slot genereP and use the name of the class to make the compare. Is it possible?

    Thank you!

     
  • Gary Riley

    Gary Riley - 2011-06-03

    Try this:

    (defrule remove-edatR""
       ?user <- (object (is-a User) (grauGenere ?grauU)(nomGenere ?nomU));
       ?program <- (object (is-a Contingut))
       (test (and (eq ?grauU gens) (eq ?nomU (class ?program))))
       =>
       (send ?program delete)
    )

     

Log in to post a comment.