home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
forth
/
compiler
/
fpc
/
source
/
interval.seq
< prev
next >
Wrap
Text File
|
1988-11-03
|
1KB
|
27 lines
\ Interval testing words. Naming convention motivated by the
\ mathematical intervals (a,b) [a,b] (a,b] and [a,b).
\ Would better names be (A,B) [A,B] ... ?
\ Application Note: In VP-Planner these four words were
\ implemented in machine code and saved approximately 500 bytes,
\ resulted in increased execution speed and better readability
\ than when actual tests were coded inline in highlevel Forth.
\ (IN) leaves a true flag if a < x < b
: (IN) ( x a b -- flag ) ( JWB 28 09 88 )
\ 2DUP < NOT ABORT" Invalid interval."
-ROT OVER < -ROT > AND ;
\ [IN] leaves a true flag if a <= x <= b , otherwise false.
: [IN] ( x a b -- flag ) ( JWB 02 10 85 )
1+ SWAP 1- SWAP (IN) ;
\ (IN] leaves a true flag if a < x <= b , otherwise false.
: (IN] ( x a b -- flag ) ( JWB 02 10 85 )
1+ (IN) ;
\ [IN) leaves a true flag if a <= x < b , otherwise false.
: [IN) ( x a b -- flag ) ( JWB 02 10 85 )
SWAP 1- SWAP (IN) ;