[Next] [Up] [Previous] [Contents] [Index]
Next: Primitives on tables Up: Linear tabling and the Previous: Linear tabling and the   Contents   Index

Example:


[IMAGE png]
      :-table dfs/2.
      :-eager_consume dfs/2.
      dfs(State,Plan):-
          is_final_state(State),!,
          Plan=[].
      dfs(State,[Move|Plan]):-
          select_move(State,Move),
          update(State,State1),
          dfs(State1,Plan).

[IMAGE png]

This program implements the depth-first search algorithm over a state space. It terminates once a plan is found. Without the eager_consume declaration, however, the program would explore all the state space and would never stop if there are infinite number of plans.



Neng-Fa Zhou () 2007-06-05