Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Forth > Re: BETWEEN
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 28 of 151 Topic 3827 of 4285
Post > Topic >>

Re: BETWEEN

by Bruce McFarling <agila61@[EMAIL PROTECTED] > Mar 20, 2008 at 02:16 PM

On Mar 18, 3:49 pm, an...@[EMAIL PROTECTED]
 (Anton Ertl)
wrote:
> Bruce McFarling <agil...@[EMAIL PROTECTED]
> writes:
> >Come to think of it, a shorter valid BETWEEN in terms of WITHIN may
> >be:
>
> >[UNDEFINED] (1) [IF] : (1) ; IMMEDIATE
> >[UNDEFINED] NOT [IF] : NOT 0= ;
> >[ELSE] 1 NOT [IF] : NOT 0= ; [THEN]
> >[THEN]
>
> >\ Circular comparison
> >\  BETWEEN is [lower ... value? ... upper]
> >\  If BETWEEN hits the top before upper, it wraps around to the bottom
>
> >: BETWEEN ( value lower upper -- inside? )
> >    1+ SWAP (1) WITHIN NOT ;

> Not particularly short in this form.  What's the point of "(1)"?

Its a comment word. When I want to stack comment in the middle of a
word, I use immediate no-ops (1) through (4) and there is a comment
like:

    \ (1) ...
.... below.

For me, four words is short. I'm not trying to fit as many as possible
into one block ... if it is blocked, it will be in a pseudo-textfile
block range.

> Anyway, rewriting this without all the ifdefs:

> : between 1+ swap within 0= ;
>
> A few tests I did look good.
>
> Looking at this closely, I see the sequence SWAP WITHIN 0=, which I
> claimed to be equivalent to WITHIN, but I tested it with, e.g.
>
> 3 3 3 within .
> 3 3 3 swap within 0= .
>
> and the results differ; so the equivalence holds only when the bounds
> are different.  The reason is that the range covered by WITHIN is the
> empty set when the two bounds are equal; SWAP is a noop in this case,
> so the 0= means that the range of SWAP WITHIN 0= covers all numbers on
> the circle.  For defining BETWEEN you need a variant of WITHIN that
> has this property.  So I believe that this definition is correct.
>
> Cool.  How did you find that?

I was do***enting the various manipulations of BETWEEN for character
testing, and started using the

    [lower ... value? ... upper]

comment to show what had happened to the inputs just before BETWEEN
executes... like,

    [lower=value?=upper]
    [upper+1 ... value? ... lower+1]
    etc.

when its duplicated, and it tickled something in my memory on modulus
arithmetic from Number theory ... in modulus arithmatic,

\{[lower...upper]} = {upper(...)lower}, or, IOW,

    A member [lower...upper] iff A not member upper(...)lower

and so if they are modulus integers, with WITHIN's semi-closed range,

[lower... value ... upper] = ~{[upper+1... value? ...)lower}

1+ is ( lower upper+1 )
SWAP is ( upper+1 lower )
WITHIN is [upper+1... value? ...)lower
NOT is ~{[upper+1... value? ...)lower}

Having this definition is useful in taking NOT-BETWEEN and trimming
down its footprint when WITHIN is assumed to be the most likely to be
coded efficiently.

: NOT-BETWEEN ( value lower upper -- flag ) \ NOT{ [lower ...
value? ... upper] }
    1+ SWAP 1+ BETWEEN ;

.... if BETWEEN is in terms of WITHIN

: NOT-BETWEEN ( value lower upper -- flag ) \ NOT{ [lower ...
value? ... upper] }
    1+ SWAP 1+ 1+ SWAP WITHIN NOT ;

-->

: NOT-BETWEEN ( value lower upper -- flag ) \ NOT{ [lower ...
value? ... upper] }
    2 1 D+ WITHIN NOT ;
 




 151 Posts in Topic:
BETWEEN
"Ed" <nospam  2008-03-11 10:05:05 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-10 23:27:36 
Re: BETWEEN
"Ed" <nospam  2008-03-12 10:59:55 
Re: BETWEEN
Coos Haak <chforth@[EM  2008-03-12 02:02:50 
Re: BETWEEN
"Ed" <nospam  2008-03-14 12:44:03 
Re: BETWEEN
Coos Haak <chforth@[EM  2008-03-14 19:55:40 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-11 23:38:22 
Re: BETWEEN
Elizabeth D Rather <er  2008-03-11 21:57:31 
Re: BETWEEN
"Ed" <nospam  2008-03-14 12:50:14 
Re: BETWEEN
Bruce McFarling <agila  2008-03-21 06:59:32 
Re: BETWEEN
Andrew Haley <andrew29  2008-03-21 15:16:33 
Re: BETWEEN
Bruce McFarling <agila  2008-03-11 20:06:28 
Re: BETWEEN
Coos Haak <chforth@[EM  2008-03-12 19:29:05 
Re: BETWEEN
William James <w_a_x_m  2008-03-12 02:28:18 
Re: BETWEEN
Bruce McFarling <agila  2008-03-12 11:56:09 
Re: BETWEEN
Coos Haak <chforth@[EM  2008-03-12 20:21:19 
Re: BETWEEN
Bruce McFarling <agila  2008-03-12 12:43:41 
Re: BETWEEN
Bruce McFarling <agila  2008-03-13 18:59:54 
Re: BETWEEN
Bruce McFarling <agila  2008-03-13 19:07:20 
Re: BETWEEN
"Ed" <nospam  2008-03-14 14:50:16 
Re: BETWEEN
Bruce McFarling <agila  2008-03-14 06:45:40 
Re: BETWEEN
Bruce McFarling <agila  2008-03-14 07:32:38 
Re: BETWEEN
Bruce McFarling <agila  2008-03-14 07:38:48 
Re: BETWEEN
Bruce McFarling <agila  2008-03-14 13:57:04 
Re: BETWEEN
Bruce McFarling <agila  2008-03-16 13:27:20 
Re: BETWEEN
Bruce McFarling <agila  2008-03-18 08:51:45 
Re: BETWEEN
anton@[EMAIL PROTECTED]   2008-03-18 19:49:37 
Re: BETWEEN
Bruce McFarling <agila  2008-03-20 14:16:42 
Re: BETWEEN
Bruce McFarling <agila  2008-03-20 14:20:37 
Re: BETWEEN
Andrew Haley <andrew29  2008-03-21 11:44:48 
Re: BETWEEN
Bruce McFarling <agila  2008-03-20 15:31:50 
Re: BETWEEN
William James <w_a_x_m  2008-03-12 02:41:44 
Re: BETWEEN
Bruce McFarling <agila  2008-03-12 08:47:12 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-12 12:14:00 
Re: BETWEEN
Bruce McFarling <agila  2008-03-12 11:14:39 
Re: BETWEEN
mhx@[EMAIL PROTECTED] (M  2008-03-12 19:29:03 
Re: BETWEEN
Jonah Thomas <jethomas  2008-03-12 14:57:02 
Re: BETWEEN
Brad Eckert <nospaambr  2008-03-14 08:23:24 
Re: BETWEEN
John Doty <jpd@[EMAIL   2008-03-14 09:33:12 
Re: BETWEEN
William James <w_a_x_m  2008-03-15 12:56:09 
Re: BETWEEN
"Ed" <nospam  2008-03-16 17:44:01 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-16 08:57:06 
Re: BETWEEN
Andrew Haley <andrew29  2008-03-17 11:02:53 
Re: BETWEEN
Elizabeth D Rather <er  2008-03-17 10:31:11 
Re: BETWEEN
John Doty <jpd@[EMAIL   2008-03-16 08:08:44 
Re: BETWEEN
"Ed" <nospam  2008-03-20 11:38:02 
Re: BETWEEN
Bruce McFarling <agila  2008-03-15 13:43:21 
Re: BETWEEN
Bruce McFarling <agila  2008-03-15 17:09:04 
Re: BETWEEN
Aleksej Saushev <asau@  2008-03-16 04:15:04 
Re: BETWEEN
Bruce McFarling <agila  2008-03-15 21:11:00 
Re: BETWEEN
Josh Grams <josh@[EMAI  2008-03-16 13:09:01 
Re: BETWEEN
Bernd Paysan <bernd.pa  2008-03-16 14:21:15 
Re: BETWEEN
Bruce McFarling <agila  2008-03-16 13:34:47 
Re: BETWEEN
Bruce McFarling <agila  2008-03-16 13:41:06 
Re: BETWEEN
Brad Eckert <nospaambr  2008-03-20 07:55:09 
Re: BETWEEN
"Ed" <nospam  2008-03-29 12:50:55 
Re: BETWEEN
Bruce McFarling <agila  2008-03-31 10:32:03 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-31 13:40:23 
Re: BETWEEN
Bruce McFarling <agila  2008-03-31 11:09:41 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-31 16:17:43 
Re: BETWEEN
Bruce McFarling <agila  2008-03-31 14:43:42 
Re: BETWEEN
Bruce McFarling <agila  2008-03-31 15:46:09 
Re: BETWEEN
Robert Spykerman <robe  2008-03-31 20:38:09 
Re: BETWEEN
Robert Spykerman <robe  2008-03-31 21:17:44 
Re: BETWEEN
"Ed" <nospam  2008-04-02 00:00:00 
Re: BETWEEN
Bruce McFarling <agila  2008-04-04 08:15:18 
Re: BETWEEN
Jonah Thomas <jethomas  2008-03-12 07:53:19 
Re: BETWEEN
Albert van der Horst <  2008-03-12 18:13:20 
Re: BETWEEN
anton@[EMAIL PROTECTED]   2008-03-13 10:17:59 
Re: BETWEEN
"Ed" <nospam  2008-03-14 13:39:47 
Re: BETWEEN
Coos Haak <chforth@[EM  2008-03-14 20:01:22 
Re: BETWEEN
mhx@[EMAIL PROTECTED] (M  2008-03-14 20:15:44 
Re: BETWEEN
Coos Haak <chforth@[EM  2008-03-14 20:22:52 
Re: BETWEEN
"Ed" <nospam  2008-03-15 12:05:20 
Re: BETWEEN
Coos Haak <chforth@[EM  2008-03-15 13:29:06 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-13 12:29:14 
Re: BETWEEN
John Doty <jpd@[EMAIL   2008-03-13 11:17:54 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-13 13:30:49 
Re: BETWEEN
John Doty <jpd@[EMAIL   2008-03-13 11:45:23 
Re: BETWEEN
David Thompson <dave.t  2008-03-31 04:27:44 
Re: BETWEEN
Bruce McFarling <agila  2008-03-12 10:58:12 
Re: BETWEEN
Bruce McFarling <agila  2008-03-12 12:35:02 
Re: BETWEEN
Jonah Thomas <jethomas  2008-03-12 14:54:19 
Re: BETWEEN
William James <w_a_x_m  2008-03-13 11:24:23 
Re: BETWEEN
John Doty <jpd@[EMAIL   2008-03-13 12:52:26 
Re: BETWEEN
William James <w_a_x_m  2008-03-13 12:17:12 
Re: BETWEEN
John Doty <jpd@[EMAIL   2008-03-13 13:33:20 
Re: BETWEEN
anton@[EMAIL PROTECTED]   2008-03-13 19:51:14 
Re: BETWEEN
William James <w_a_x_m  2008-03-13 14:48:22 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-13 18:04:08 
c-version, was Re: BETWEEN
Albert van der Horst <  2008-03-14 09:09:50 
Re: BETWEEN
anton@[EMAIL PROTECTED]   2008-03-14 11:37:38 
Re: BETWEEN
William James <w_a_x_m  2008-03-13 14:58:01 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-13 18:17:33 
Re: BETWEEN
John Doty <jpd@[EMAIL   2008-03-13 16:48:39 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-13 19:14:32 
Re: BETWEEN
John Doty <jpd@[EMAIL   2008-03-13 17:31:16 
Re: BETWEEN
Albert van der Horst <  2008-03-14 09:30:54 
Re: BETWEEN
Aleksej Saushev <asau@  2008-03-15 02:07:32 
Re: BETWEEN
John Doty <jpd@[EMAIL   2008-03-14 19:21:08 
Re: BETWEEN
Aleksej Saushev <asau@  2008-03-15 14:33:26 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-15 11:29:17 
Re: BETWEEN
John Doty <jpd@[EMAIL   2008-03-15 11:00:02 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-15 13:34:31 
Re: BETWEEN
John Doty <jpd@[EMAIL   2008-03-15 11:48:39 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-15 14:02:32 
Re: BETWEEN
Aleksej Saushev <asau@  2008-03-15 21:27:37 
Re: BETWEEN
Aleksej Saushev <asau@  2008-03-15 20:15:10 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-15 13:48:20 
Re: BETWEEN
Albert van der Horst <  2008-03-16 13:43:28 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-16 11:38:32 
Re: BETWEEN
John Doty <jpd@[EMAIL   2008-03-15 17:11:08 
Re: BETWEEN
Aleksej Saushev <asau@  2008-03-16 04:07:29 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-14 23:44:25 
Re: BETWEEN
Aleksej Saushev <asau@  2008-03-15 15:05:03 
Re: BETWEEN
John Doty <jpd@[EMAIL   2008-03-15 17:36:43 
Re: BETWEEN
Aleksej Saushev <asau@  2008-03-16 04:12:06 
Re: BETWEEN
Jonah Thomas <jethomas  2008-03-14 08:19:15 
Re: BETWEEN
Andrew Haley <andrew29  2008-03-14 14:18:34 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-18 00:00:17 
Re: BETWEEN
Andrew Haley <andrew29  2008-03-18 12:13:01 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-18 11:41:04 
Re: BETWEEN
Andrew Haley <andrew29  2008-03-18 16:15:39 
Re: BETWEEN
"Ed" <nospam  2008-03-15 12:40:01 
Re: BETWEEN
Andrew Haley <andrew29  2008-03-15 10:05:21 
Re: BETWEEN
"Ed" <nospam  2008-03-16 16:56:01 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-16 08:50:11 
Re: BETWEEN
"Ed" <nospam  2008-03-18 10:48:20 
Re: BETWEEN
Coos Haak <chforth@[EM  2008-03-18 00:55:08 
Re: BETWEEN
"Ed" <nospam  2008-03-20 11:36:33 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-18 00:03:13 
Re: BETWEEN
Duke Normandin <dukeof  2008-03-17 23:28:44 
Re: BETWEEN
Coos Haak <chforth@[EM  2008-03-18 00:52:09 
Re: BETWEEN
Andrew Haley <andrew29  2008-03-18 12:11:31 
Re: BETWEEN
Duke Normandin <dukeof  2008-03-18 00:51:56 
Re: BETWEEN
John Doty <jpd@[EMAIL   2008-03-17 19:10:30 
Re: BETWEEN
Duke Normandin <dukeof  2008-03-18 05:40:19 
Re: BETWEEN
Coos Haak <chforth@[EM  2008-03-18 18:32:33 
Re: BETWEEN
Duke Normandin <dukeof  2008-03-19 02:09:21 
Re: BETWEEN
Jonah Thomas <jethomas  2008-03-14 10:33:48 
Re: BETWEEN
Jonah Thomas <jethomas  2008-03-14 10:40:29 
Re: BETWEEN
William James <w_a_x_m  2008-03-14 09:21:41 
Re: BETWEEN
Bruce McFarling <agila  2008-03-14 09:49:52 
Re: BETWEEN
Jonah Thomas <jethomas  2008-03-16 10:24:22 
Re: BETWEEN
Jerry Avins <jya@[EMAI  2008-03-16 11:35:57 
Re: BETWEEN
Andrew Haley <andrew29  2008-03-17 10:37:08 
Re: BETWEEN
Bruce McFarling <agila  2008-03-20 04:32:31 
Re: BETWEEN
Jonah Thomas <jethomas  2008-03-31 17:21:03 
Re: BETWEEN
"Ed" <nospam  2008-04-05 01:28:53 
Re: BETWEEN
Jonah Thomas <jethomas  2008-03-31 18:05:58 
Re: BETWEEN
Jonah Thomas <jethomas  2008-04-04 14:46:19 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 14:06:19 CDT 2008.