home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / p3_11bs.seq < prev    next >
Text File  |  1990-04-07  |  969b  |  46 lines

  1. \ Balraj Sidhu   Set: 14D4
  2. \ Comp 462 - Forth
  3. \ Date: April 7, 1990
  4. \ Problem 3.11
  5.  
  6.  
  7. \ leave a true flag is a < x < b
  8. : (in) ( x a b -- flag )
  9. \ remove the comment from the line below for run time error checking
  10.         2dup < not abort" Invalid interval."
  11.         -rot over < -rot > and ;
  12.  
  13. \ [in] leaves a true flag if a <= x <= b , otherwise false
  14. : [in] ( x a b -- flag ) between ;
  15.  
  16. \ (in] leaves a true flag if a <  x <= b , otherwise false
  17. : (in] ( x a b -- flag ) swap 1+ swap between ;
  18.  
  19. \ [in) leaves a true flag if a <= x <  b , otherwise false
  20. : [in) ( x a b -- flag ) within ;
  21.  
  22. cr
  23.  4 5 9 .s (in] . cr
  24.  7 5 9 .s (in] . cr
  25.  9 5 9 .s (in] . cr
  26. 10 5 9 .s (in] . cr
  27.  
  28. cr
  29.  4 5 9 .s (in) . cr
  30.  7 5 9 .s (in) . cr
  31.  9 5 9 .s (in) . cr
  32. 10 5 9 .s (in) . cr
  33.  
  34. cr
  35.  4 5 9 .s [in) . cr
  36.  5 5 9 .s [in) . cr
  37.  9 5 9 .s [in) . cr
  38. 10 5 9 .s [in) . cr
  39.  
  40. COMMENT:
  41.  
  42. When you try to use a invalid intervals, you get a false flag.
  43.  
  44. COMMENT;
  45.  
  46.