chapter10 - Chapter 10: Procedural Programming Expert...

Info iconThis preview shows pages 1–10. 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 DocumentRight 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 DocumentRight 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 DocumentRight 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 DocumentRight 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
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
Background image of page 9

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

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 40

chapter10 - Chapter 10: Procedural Programming Expert...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online