Iterates over a set of bindings.


A variable that iterates from 1 to the number of bindings.
A variable that contains the total number of bindings.
The variable whose bindings are to be counted.
A non-ground clause containing ?variable.


   ((:FOR ?i ?n ?leg (legs Spot ?leg))
    (:PRINTLN "Leg " ?i " of " ?n " is " ?leg)

  would produce:

   Leg 1 of 4 is Spot-leg1
   Leg 2 of 4 is Spot-leg2
   Leg 3 of 4 is Spot-leg3
   Leg 4 of 4 is Spot-leg4

Success criteria

Always succeeds. if clause fails or produces no bindings, the size variable will be zero and index and variable will be unbound.

Failure criteria

Never fails.


Successive :FOR clauses act like nested For loops in a standard programming language.

Related commands

Back to...

Algernon commands
Algernon Documentation Central
Algernon home page