Re: efficient comparison



CBFalconer <cbfalconer@xxxxxxxxx> writes:

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.

Indeed I am.

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;

Well, that much I knew (I used to teach Pascal). The question is what
is the least that one can reply on when using Pascal? Has Pascal
moved on so that the SET OF idea is more useful? You seem to be
knowledgeable about modern Pascal standards (the last one I used was
the first ISO standard Pascal) so I thought I'd ask.

In particular, for the OP's question, can one have sets of arbitrary
strings?

--
Ben.
.



Relevant Pages

  • Re: XML Diff utility?
    ... > but are impractical for the xml files I'm comparing which contain ... > attribute lines 3k chars long. ... What about writting a little tool inserts a linebreak after each ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: get(char*, num, delim) question
    ... Francis Bell wrote in message ... Why is first of 2 chars but you read 4 chars into it? ... You're comparing the value of the pointers (ie. comparing the memory ... Use std::strcmp from (same as strcmp ...
    (comp.lang.cpp)