24.11.2014 Views

flex Expert System Toolkit - LPIS

flex Expert System Toolkit - LPIS

flex Expert System Toolkit - LPIS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

7. Knowledge Specification Language 69<br />

The precedence of operators can be overridden by enclosing the expression<br />

within brackets.<br />

Examples<br />

( 1 - 2 ) * ( 3 + 4 )<br />

( its temp times its volume ) to the power of 2<br />

Dereferencing<br />

Unlike Prolog, expressions in <strong>flex</strong> are automatically dereferenced and<br />

evaluated when required. For example, any reference to the name of a slot<br />

or a global variable will automatically cause that slot or variable's current<br />

value to be accessed and used.<br />

This dereferencing can be suppressed by prefixing the term with the $<br />

symbol. Any term prefixed with $ will be taken literally and no attempt will<br />

be made to evaluate it as a <strong>flex</strong> entity. This means that the name of a frame<br />

or attribute when prefixed by $ will be treated simply as text with no<br />

reference to its <strong>flex</strong> status.<br />

For instance, consider the following code.<br />

action writer ;<br />

do ask toys<br />

and write( $toys )<br />

and nl<br />

and write( toys ) .<br />

question toys<br />

Which toys would you like? ;<br />

choose some of doll, teddy, train, jigsaw, paints .<br />

If we now execute the writer action on the Prolog command line, we will<br />

see that we get back two written values. The first is the absolute value of<br />

toys, namely the atom itself (because of the use of the $ symbol), and the<br />

second is the current value that toys evaluates to, which in this case, is the<br />

list of items selected from the toys question.<br />

?- writer.<br />

toys<br />

[teddy, train, paints]<br />

<strong>flex</strong> toolkit

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!