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.


Copying a Value:

   (SetValue (Concept "foo") (Predicate "some key")
      (ValueOf (Concept "bar") (Predicate "other key"))))

Performing a computation:

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

   (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.