Code: Select all
class predicates
doAction : (integer SelectionIndex, predicate ExecuteSelection [out]) determ.
clauses
doAction(1, one).
doAction(2, two).
doAction(_, oops).
class predicates % to be executed, dependent upon the input to doAction/2
one : ().
two : ().
oops : ().
clauses
one() :-
stdio::write("\n", 1).
two() :-
stdio::write("\n", 2).
oops() :-
stdio::write("\nOOPS!").
clauses
run() :-
N = 1, % index of a menu selection
doAction(N, Pred),
nothing(Pred),
% What to do to execute 'Pred' here ???
!.
run() :-
nothing("FAILED").