FloatValue

From OpenCog
Jump to: navigation, search

The FloatValue is a kind of value. It allows for the specification of a vector of floats. It is the base type for all truth values.

Example usage:

(FloatValue 0.1 0.2 0.3)

creates a value. To associate it with an atom, say:

(cog-set-value! (Concept "abc") (Predicate "key")(FloatValue 0.1 0.2 0.3))

The above sets the value on ConceptNode "abc", placing it at the key of PredicateNode "key". To fetch it, say

 (cog-value (Concept "abc") (Predicate "key"))

To get the actual floating-point values back, use either cog-value->list to get the whole list, or use cog-value-ref to get the n'th element. Example:

(cog-value->list (cog-value (Concept "abc") (Predicate "key")))

(cog-value-ref (cog-value (Concept "abc") (Predicate "key")) 2)