Stores a value in a variable so that it can be used in a later clause.


A variable to be bound.
An expression that evaluates to a value.


  (:BIND ?x 1)
  (:BIND ?y "14")
  (:BIND ?z (:JAVA (org.algernon.test.MiscellanyTest.date1)))
  (:BIND ?w (:LISP (- ?z ?x 14)))
  (:BIND ?v (:LISP (/ ?x 14)))

;; Sequential Fibonacci
(tell  ((:BIND ?x1 1)
        (:BIND ?x2 1)
        (:PRINTLN ?x1)
        (:PRINTLN ?x2)
        (:BIND ?x3 (:LISP (+ ?x1 ?x2)))
        (:PRINTLN ?x3)
        (:BIND ?x1 ?x2)
        (:BIND ?x2 ?x3)
        (:BIND ?x3 (:LISP (+ ?x1 ?x2)))
        (:PRINTLN ?x3)
        (:BIND ?x1 ?x2)
        (:BIND ?x2 ?x3)
        (:BIND ?x3 (:LISP (+ ?x1 ?x2)))
        (:PRINTLN ?x3)
        (:BIND ?x1 ?x2)
        (:BIND ?x2 ?x3)
        (:BIND ?x3 (:LISP (+ ?x1 ?x2)))))

Success criteria

Always succeeds unless an error occurs in the evaluation of the expression.

Failure criteria

Fails only if an error occurs during evaluation of the expression.


Unlike earlier versions of Algernon, a variable can be bound more than once. If reasoning branches before the :BIND command, each reasoning branch will have a separate copy of the variable. In that case, the :BIND command will only affect the copy of the variable in the current reasoning branch.

See also the syntax for calling external functions.

Related commands

Back to...

Algernon commands
Algernon Documentation Central
Algernon home page