From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.1 required=5.0 tests=BAYES_20,INVALID_DATE, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!rpi!dali!uakari.primate.wisc.edu!samsung!munnari.oz.au!bruce!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.ada Subject: Re: Public domain set manipulation package Summary: array of boolean Keywords: Wanted Message-ID: <3108@goanna.cs.rmit.oz.au> Date: 30 May 90 09:38:06 GMT References: <209@trwacs.UUCP> Organization: Comp Sci, RMIT, Melbourne, Australia List-Id: In article <209@trwacs.UUCP>, epstein@trwacs.UUCP (Jeremy Epstein) writes: > I need a package that lets me declare a set of named items. > The ideal way would be a set of enumerated values. > I only need one operation on the set: examine whether a > particular element is in the set. The Ada equivalent of Pascal's "set of EnumType" is "array (EnumType) of BOOLEAN". For example, type COLOR is (WHITE, RED, YELLOW, GREEN, BLUE, BROWN, BLACK); -- LRM 3.3.1 type COLOR_SET is array(COLOR) of BOOLEAN; c: COLOR; s: COLOR_SET; The Ada equivalent of a Pascal set expression "[...]" is an array aggregate, LRM 4.3.2, e.g. s := COLOR_SET'(RED=>TRUE, GREEN=>TRUE, others=>FALSE); The Ada equivalent of Pascal's "c IN s" is just "s(c)", e.g. if s(c) then -- the colour c is in the set of colours s The boolean operators and, or, xor, not apply to one dimensional boolean arrays (LRM 4.5.1, 4.5.6) and equality tests = /= work the way you would expect (LRM 4.5.2). So you see that full support for Pascal-like sets is already a standard part of the Ada language. -- "A 7th class of programs, correct in every way, is believed to exist by a few computer scientists. However, no example could be found to include here."