:FOR

Purpose

Iterates over a set of bindings.

Parameters

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

Examples

   ((: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.

Notes

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