Re: efficient comparison
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Tue, 28 Aug 2007 17:31:15 -0400
Ben Bacarisse wrote:
CBFalconer <cbfalconer@xxxxxxxxx> writes:
bob@xxxxxxxxxxxxxx wrote:
Let's say you have a set of names called set A. You also have a
different set of names called set B. What is the most efficient
way of comparing the sets?
By comparison, I mean finding the names that need to be added to
set B and deleted from set B to form set A.
Use Pascal, and then those are all primitive operations. I kid you
not.
Lots of languages have sets but Pascal's sets used to be so limited as
to be almost useless of general versions of the above problem. Does
modern Pascal have sets of anything more flexible that enumerated
types?
I think you are worrying about the restriction to things that can
be enumerated. Systems vary as to the sizes of that enumeration
handleable. But once you have it, things are easy. Chars. are
automatically enumerated, so:
TYPE
ucase = 'A' .. 'Z';
lcase = 'a' .. 'z';
VAR
upper = SET OF ucase;
lower = SET OF lcase;
alpha = SET OF char;
...
alpha = upper + lower;
...
IF ch IN alpha THEN (* use alpha char *);
IF ch IN lower THEN (* use lower case *);
etc. Or we could someplace declare the known names:
CONST
name00 = 0; name01 = 1; name02 = 2; ...
TYPE
names = name00, name01, name02, (* until enough *) nomeNN;
VAR
actualnames = ARRAY[names];
...
actualnames[0] = "blah"; ....
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
--
Posted via a free Usenet account from http://www.teranews.com
.
- Follow-Ups:
- Re: efficient comparison
- From: Ben Bacarisse
- Re: efficient comparison
- References:
- efficient comparison
- From: bob
- Re: efficient comparison
- From: CBFalconer
- Re: efficient comparison
- From: Ben Bacarisse
- efficient comparison
- Prev by Date: Re: Problem Debugging C Program
- Next by Date: Re: Key-press detection
- Previous by thread: Re: efficient comparison
- Next by thread: Re: efficient comparison
- Index(es):
Relevant Pages
|