[comp.lang.pascal] really want a real set ?

ZCCBJSB%EB0UB011.BITNET@cunyvm.cuny.edu (Josep Sau B.) (11/26/90)

Message <9011260748.aa11950@VIM.BRL.MIL> said:

>Does anybody know how can I build a SET with Real (or double)
>elements in Turbo Pascal? I Only need a SET with 15 real numbers.
>
>Once SET requires subranges with no more than 256 itens I can not
>make a set of word (my real numbers have only one place after
>the decimal point, so I could multiply by 10, solving the problem, but
>the range from the first to the last overcome 256).
>
>I've tried to make a TYPE with these numbers but Turbo gives an
>error saying "Error 2: Identifier expected" .

If those real values are variable, forget it, you can't use the
set structure.

If those real values are constant, you may do thru with this trick:

Declare a const array of real, and use the ordinal index type
to build up the set to work with.

TYPE
   IndexForRealsArray = 1..NumberOfRealsNeeded;
   RealSet = SET OF IndexForRealsArray;
CONST
   MyReals : ARRAY IndexForRealArrays! OF REAL =
   (   3.1, 4.5, 7.8...the reals you need...);

...code to check for 4.5
  IF 2 IN RealSetVar THEN... (* MyReals2! in the set...*)


If those values are significative I suggest you to declare an
enumerated type for that index like this:

TYPE
   IndexForRealsArray =
   (MyFirstReal, TheOtherReal, MyBelovedReal, TheTrickyReal...);

A side of all this, you can only declare an enumerated type using
constant identifiers, not numbers, be they integer or real).

Hope that could be of use.




--Josep Sau B. <ZCCBJSB@EB0UB011>
------------------------------------------------------------------
'Every science needs the right words to be expressed the right way'
           Raimundus Lulius (Catalan philosopher)
------------------------------------------------------------------