TimesLink

From OpenCog
Jump to: navigation, search

The TimesLink is a special case of an FunctionLink that knows how to multiply numbers together. For example

(cog-execute!
   (TimesLink
      (NumberNode 2)
      (NumberNode 3)))

will yield

 (NumberNode "6.000000")

as a result.

The TimesLink is a "clear-box" link (as opposed to a "black box" link), in that it is "obvious" what it does. Clear-box links can be reasoned about and reduced. The cog-reduce! function can perform reduction on clear-box links. Thus, for example:

(cog-reduce!
   (TimesLink
      (VariableNode "$x")
      (NumberNode 2)
      (NumberNode 3)))

will return

 (TimesLink
    (VariableNode "$x")
    (NumberNode 6)

TimesLink and PlusLink both use FoldLink to do reduction of repeated terms.

See also