Path: utzoo!attcan!uunet!willett!ForthNet From: ForthNet@willett.UUCP (ForthNet articles from GEnie) Newsgroups: comp.lang.forth Subject: F-PC Forth Tutorial Message-ID: <1058.UUL1.3#5129@willett.UUCP> Date: 1 Jun 90 03:45:59 GMT Organization: Latest link in the ForthNet chain. (Pgh, PA) Lines: 72 Date: 05-30-90 (22:56) Number: 20 (Echo) To: JACK BROWN Refer#: NONE From: ROY RICE Read: NO Subj: LESSON3, EX3.11-12 Status: PUBLIC MESSAGE \ RARL3D.SEQ ccontinuation of lesson 3 \ (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 ; \ Exercise 3.12 \ Write definitions of [IN] (IN] and [IN) that do not use (IN) or \ each other! : [IN) ( x a b -- f ) \ true if a <= x < b 2DUP < NOT ABORT" Invalid interval." -ROT OVER <= -ROT > AND ; : (IN] ( x a b -- f ) \ true if a < x <= b 2DUP < NOT ABORT" Invalid interval." -ROT OVER < -ROT >= AND ; : [IN] ( x a b -- f ) \ true if a <= x <= b 2DUP < NOT ABORT" Invalid interval." -ROT OVER <= -ROT >= AND ; \ ex 3.11 tests using my words : .F ( f -- ) \ display flag IF ." true " ELSE ." false " then ; : TESTIN ( x a b -- ) \ test the interval words 2DUP < NOT ABORT" Invalid interval." CR 3DUP SWAP ." a = " . 4 SPACES SWAP ." x = " . 4 SPACES ." b = " . CR ." (IN) [IN) (IN] [IN] " CR ." a