Message from discussion Is there a better way?
Received: by 10.224.193.72 with SMTP id dt8mr18710684qab.7.1351684704157;
Wed, 31 Oct 2012 04:58:24 -0700 (PDT)
Received: by 10.52.76.36 with SMTP id h4mr5746438vdw.17.1351684704134; Wed, 31
Oct 2012 04:58:24 -0700 (PDT)
Date: Wed, 31 Oct 2012 04:58:24 -0700 (PDT)
Injection-Info: k20g2000vbj.googlegroups.com; posting-host=18.104.22.168; posting-account=W9Y9TgoAAAAe3pS80Z-tHCcq6DoIqBGn
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64;
Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR
3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; MS-RTC LM 8; ),gzip(gfe)
Subject: Is there a better way?
From: Mark Wills <forthfr...@gmail.com>
Injection-Date: Wed, 31 Oct 2012 11:58:24 +0000
Content-Type: text/plain; charset=ISO-8859-1
The following routine is checking to see if a string is "}}" i.e.
consists of two consequtive right curly braces.
: }}? ( addr len -- addr len flag)
dup 2= if
over dup c@ swap 1+ c@ 125 = swap 125 = and
As can be seen, the first check is the length; if the length is not
exactly 2 then we just return false. If the length is 2 then we check
to see if both characters are ASCII 125. That's the bit I am looking
at and saying "Meh... seems a bit convoluted/lengthy.
Is there a better way?
I was thinking maybe:
... c@ 125 OR swap 1+ c@ 125 OR 125 XOR 0=
Which is perhaps "cleverer" but not as clear as to the intention of
the code and no shorter...