TrueLink

From OpenCog
Jump to: navigation, search

The TrueLink is a type of Link that, when evaluated, always evaluates to true. It is typically used to wrap other atoms that either do not return a truth value, or whose truth value should be ignored (and replaced by "true").

Example Usage

(use-modules (opencog) (opencog exec))

; Initialize count to zero
(State (Anchor "sum") (Number 0))

; cog-execute! TrueLink will cause the get/put to run.
(cog-execute!
   (True
      (Put
        (State (Anchor "sum") (Variable "$x")) 
        (Plus (Number 1) (Get (State (Anchor "sum") (Variable "$y")))))))

; Verify the change of state
(cog-execute! (Get (State (Anchor "sum") (Variable "$x"))))

See also