StreamValueOfLink

From OpenCog
Jump to: navigation, search

The StreamValueOf Link is a variation on the ValueOfLink that can sample values from a stream.

For example:

(cog-set-value! (Concept "a") (Predicate "key") (RandomStream 3))

The above attaches a random-number generator to the concept at the given key. The random stream can be sampled through repeated access:

(cog-execute! (StreamValueOf (Concept "a") (Predicate "key")))
(cog-execute! (StreamValueOf (Concept "a") (Predicate "key")))
(cog-execute! (StreamValueOf (Concept "a") (Predicate "key")))

See examples/atomspace/stream.scm and examples/atomspace/flow-formulas.scm for detailed examples.