home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
forth
/
compiler
/
fpc
/
source
/
p3_11bs.seq
< prev
next >
Wrap
Text File
|
1990-04-07
|
969b
|
46 lines
\ Balraj Sidhu Set: 14D4
\ Comp 462 - Forth
\ Date: April 7, 1990
\ Problem 3.11
\ leave a true flag is a < x < b
: (in) ( x a b -- flag )
\ remove the comment from the line below for run time error checking
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 ) between ;
\ (in] leaves a true flag if a < x <= b , otherwise false
: (in] ( x a b -- flag ) swap 1+ swap between ;
\ [in) leaves a true flag if a <= x < b , otherwise false
: [in) ( x a b -- flag ) within ;
cr
4 5 9 .s (in] . cr
7 5 9 .s (in] . cr
9 5 9 .s (in] . cr
10 5 9 .s (in] . cr
cr
4 5 9 .s (in) . cr
7 5 9 .s (in) . cr
9 5 9 .s (in) . cr
10 5 9 .s (in) . cr
cr
4 5 9 .s [in) . cr
5 5 9 .s [in) . cr
9 5 9 .s [in) . cr
10 5 9 .s [in) . cr
COMMENT:
When you try to use a invalid intervals, you get a false flag.
COMMENT;