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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5430b81ad265fc75 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-04-14 11:46:14 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sjc-peer.news.verio.net!news.verio.net!iad-read.news.verio.net.POSTED!not-for-mail From: Dr Nancy's Sweetie Subject: Re: Array Of Constant Strings? Newsgroups: comp.lang.ada Organization: Rowan University References: <19guh-2f4.ln1@beastie.ix.netcom.com> <3E4D46B9.6060805@acm.org> User-Agent: tin/1.4.6-20020816 ("Aerials") (UNIX) (SunOS/5.8 (sun4u)) Message-ID: Date: Mon, 14 Apr 2003 18:43:26 GMT NNTP-Posting-Host: 150.250.64.69 X-Complaints-To: abuse@verio.net X-Trace: iad-read.news.verio.net 1050345806 150.250.64.69 (Mon, 14 Apr 2003 18:43:26 GMT) NNTP-Posting-Date: Mon, 14 Apr 2003 18:43:26 GMT Xref: archiver1.google.com comp.lang.ada:36138 Date: 2003-04-14T18:43:26+00:00 List-Id: Last February, I wrote about setting arrays of constant strings that were always the same length and never changed. I got some useful help on the subject, and a few people expressed concerns such as: > If all the strings are always the same length, then using fixed > length strings is even simpler. However, I would tend to be > suspicious of such a requirement; things like that are almost > always changed later. and > Well, we don't know why the OP wants same-length strings, but > I agree -- such a restriction seems suspicious. I wanted to reply at the time, but couldn't, because the question went to my version of the sample solution of a problem for a programming contest. Keeping the problem a secret before the contest is obviously necessary. As we've had the contest (last Saturday), I can explain. The problem involved parsing out the 95 bits encoded by a UPC-A bar code, with the bits represented as a string of 1s and 0s. You can read the whole thing at , but the short version is that each digit in the UPC code is represented by 7 bits, and so the student programs have to split the input string into 7-character chunks and then check each substring against a table to see which digit it's supposed to be. Such a limitation is usually a bad idea, but (a) the UPC-A code is not likely to change much any time soon, given the huge investment in equipment which currently supports it, and (b) for the contest problem, I get to define any limits I like. 8-) The relevant snippets of code are here: --------------- -- Constants -- values from problem description --------------- Bit_String_Size : constant Integer := 7; [...] subtype Bit_String is String(1..Bit_String_Size); [...] -- type for bitstring lookup table type Encoding_Array is array(0..9) of Bit_String; -- Lookup tables for extracted bit strings -- (encodings taken from problem description) Left_Encoding : constant Encoding_Array := ("0001101", "0011001", "0010011", "0111101", "0100011", "0110001", "0101111", "0111011", "0110111", "0001011"); Right_Encoding : constant Encoding_Array := ("1110010", "1100110", "1101100", "1000010", "1011100", "1001110", "1010000", "1000100", "1001000", "1110100"); There are other ways to attack this, of course (make a 128-entry table and interpret the strings as binary numbers to give a direct lookup, eg), but I wanted a program whose operation would be understandable to high school students. Thanks for all your help! Darren Provine ! kilroy@elvis.rowan.edu ! http://www.rowan.edu/~kilroy "Fred Rogers was not only the nicest man I ever met, he was the nicest man ANYONE ever met." -- Robert X. Cringely