Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
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)
MIME-Version: 1.0
Received: by 10.52.76.36 with SMTP id h4mr5746438vdw.17.1351684704134; Wed, 31
 Oct 2012 04:58:24 -0700 (PDT)
Path: gf5ni7629245qab.0!nntp.google.com!c7no543562qap.0!postnews.google.com!k20g2000vbj.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 31 Oct 2012 04:58:24 -0700 (PDT)
Complaints-To: groups-abuse@google.com
Injection-Info: k20g2000vbj.googlegroups.com; posting-host=144.177.35.1; posting-account=W9Y9TgoAAAAe3pS80Z-tHCcq6DoIqBGn
NNTP-Posting-Host: 144.177.35.1
User-Agent: G2/1.0
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)
Message-ID: <70a117c1-ba9f-474b-97f3-6440be3d4573@k20g2000vbj.googlegroups.com>
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
  else
    false
  then ;

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...