SetValueLink

From OpenCog
Jump to: navigation, search

The SetValueLink is an executable Link that can be used to update arbitrary Values on a given Atom, given some source that provides a Value. Such sources include other Atoms, in which case the Value is copied, or it may be a Lambda or DefinedSchema, which computes a new Value, or a GroundedSchemaNode, which can call back into scheme or python to obtain a Value.

A special case of this is SetTVLink, which can be used to update TruthValues.

Examples

Copying a Value:

(cog-execute!
   (SetValue (Concept "foo") (Predicate "some key")
      (ValueOf (Concept "bar") (Predicate "other key"))))

Performing a computation:

(DefineLink
   (DefinedSchema "triangle numbers")
   (Lambda
      (Variable "$X")
      (Divide
         (Times (Variable "$X") (Plus (Variable "$X") (Number 1)))
         (Number 2))))

(cog-execute!
   (SetValue (Concept "bar") (Predicate "other key")
      (DefinedSchema "triangle numbers")
      (ValueOf (Concept "foo") (Predicate "some key"))))


A detailed exploration can be found in the /examples/atomspace/flows.scm file.