{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

chapter10 - Chapter 10 Procedural Programming Expert...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 10: Procedural Programming Expert Systems: Principles and Programming, Fourth Edition
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Expert Systems: Principles and Programming, Fourth Edition 2 Procedural Function CLIPS provides several functions for controlling the flow of execution: if function while function switch function loop-for-count function progn$ function break function halt function
Background image of page 2
Expert Systems: Principles and Programming, Fourth Edition 3 if Function General format: (if <predicate-expression> then <expression>+ [else <expression>+]) 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).
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Expert Systems: Principles and Programming, Fourth Edition 4 while Function General format: (while <predicate-expression> [do] <expression>*) The predicate expression is evaluated before actions of the body are executed. If the evaluation is anything other than FALSE, expressions in the body are executed; if FALSE, control passes to the next statement after the while.
Background image of page 4
Expert Systems: Principles and Programming, Fourth Edition 5 switch Function General format: (switch <test-expression> <case-statement>* [<default-statement>]) 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).
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Expert Systems: Principles and Programming, Fourth Edition 6 loop-for-count Function General format: (loop-for-count <range-spec> [do] <expression*) The body of the function is executed a given number of times, depending on <range-spec>. This is similar to the “for” loop structure in most high-level languages.
Background image of page 6
Expert Systems: Principles and Programming, Fourth Edition 7 progn$ Function General format: (progn$ <list-spec> (expression>*) <list-spec> can be : <multifield-expression> - body is executed once for each field <list-variable> - field of current iteration is retrieved by referencing variable. Special variable is created by appending –index to <list-variable> - index of current iteration
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Expert Systems: Principles and Programming, Fourth Edition 8 break Function General format: (break) 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.
Background image of page 8
Expert Systems: Principles and Programming, Fourth Edition 9 halt Function General format: (assert (phrase halt)) The halt function can be used on the RHS of a rule to stop execution of rules on the agenda. When called, no further actions will be executed from the RHS of the rule being fired and control returns to the top-level prompt.
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Expert Systems: Principles and Programming, Fourth Edition 10 The Deffunction Construct CLIPS allows one to define functions similar to the way it is done in procedural languages.
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}