Re: efficient comparison



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

.



Relevant Pages

  • Re: Windows.forms.keys collection
    ... The key code for a lower case 's' is 115, but the Keys enumeration does not ... make a distinction between lower and upper case. ... This all assumes that you're dealing strictly with alphabetic characters. ... I've found that when I convert the char, ...
    (microsoft.public.dotnet.framework)
  • Windows.forms.keys collection
    ... I have the below code for sending each character in a string as a Keys.x enumeration. ... I've found that when I convert the char, it does not match the enumeration item index and thereby generates a very random output. ... Dim strCaseID As String = "s" ...
    (microsoft.public.dotnet.framework)
  • Re: how to get a double from the command line
    ... int main(int argc, char* *argv) { ... double alpha, beta; ...
    (comp.lang.c)
  • Re: How to change the starting address of a structure element?
    ... "alpha" is the name of an array. ... > char *digit; ... > void printstruct; ... > struct demo an; ...
    (comp.lang.c)
  • Re: Alternative to Enum string values as return types and parameters
    ... What I would do is use an enumeration with numbers. ... the string that is passed in the constructor. ... > public enum HOW_GOOD ... The dataset table results will have the char value too. ...
    (microsoft.public.dotnet.languages.csharp)