AssignLink

From OpenCog
Jump to: navigation, search

Deprecated -- you should probably use PutLink instead. PutLink is more flexible and is .. prettier.

The AssignLink combines the actions of InsertLink and RemoveLink into one. When the AssignLink is executed with the cog-execute! function, or with the pattern matcher, the previous version is removed, and the new version is inserted. The AssignLink behaves like the assignment operator (viz the = sign in C++, python, perl) in procedural programming languages.

AssignLink, InsertLink and RemoveLink have the form of a special case of a SignatureLink.

Example

Executing the below, either with cog-execute! or with the pattern matcher,

  (AssignLink
     (TypeNode "EvaluationLink")
     (PredicateNode "some property")
     (ListLink
        (ConceptNode "thing A")
        (ConceptNode "alternative B"))))

will cause the EvaluationLink to be created:

 (EvaluationLink
     (PredicateNode "some property")
     (ListLink
        (ConceptNode "thing A")
        (ConceptNode "alternative B"))))

The AssignLink is equivalent to performing a remove first:

  (RemoveLink
     (TypeNode "EvaluationLink")
     (PredicateNode "some property")
     (TypeNode "ListLink"))

followed by an insert:

  (InsertLink
     (TypeNode "EvaluationLink")
     (PredicateNode "some property")
     (ListLink
        (ConceptNode "thing A")
        (ConceptNode "alternative B"))))