26-07-2012, 03:06 PM
Procedural Programming
Procedural Programming.ppt (Size: 387.5 KB / Downloads: 49)
if Function
The predicate expression is first evaluated. If the condition is anything other than FALSE, the THEN clause actions are executed; otherwise, the ELSE actions are executed (unless omitted).
switch Function
Test-expression is evaluated first. Each comparison expression is then evaluated in order defined and if it matches the value of comparison expression, actions after then are executed, then termination. If no match, default statement actions are executed (if present).
break Function
The break function terminates the execution of the while, loop-for-count, or progn$ function in which it is immediately contained. It causes early termination of a loop when a specified condition has been met.
The Deffunction Construct
CLIPS allows one to define functions similar to the way it is done in procedural languages.
New functions are defined using the deffunction construct:
Wildcard Parameters
If all arguments in the parameter list of a deffunction are single-field variables:
1-1 correspondence between these parameters and the number of arguments that must be passed when the deffunction is called.
If the last parameter declared in a deffunction is a multifield variable (wildcard parameter)
Deffunction can be called with more arguments than are specified in the parameter list.