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,8493c7e8c09c4895 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-20 09:40:15 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!elnk-pas-nf1!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: beginner array question References: <92bfc3dd.0311200234.2b74b41f@posting.google.com> In-Reply-To: <92bfc3dd.0311200234.2b74b41f@posting.google.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <207vb.7124$sb4.1469@newsread2.news.pas.earthlink.net> Date: Thu, 20 Nov 2003 17:40:14 GMT NNTP-Posting-Host: 63.184.33.54 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.news.pas.earthlink.net 1069350014 63.184.33.54 (Thu, 20 Nov 2003 09:40:14 PST) NNTP-Posting-Date: Thu, 20 Nov 2003 09:40:14 PST Xref: archiver1.google.com comp.lang.ada:2750 Date: 2003-11-20T17:40:14+00:00 List-Id: lolo27 wrote: > generic > ---------general parameters----------- > type Someting is(<>); > type something_array is Array (integer range<>) of Someting ; > > --------------------------------------------------- > in the adb file i want to ask the following > function is_final(current_state:Someting ;final:something_array ) > return boolean is > begin > if current_state in final'First..final'Last then > return true; > else > return false; > end if; > end is_final; There are a couple of problems here. "in" tests for subtype membership. Final'First .. Final'Last (equivalent to Final'range) is a subtype of Integer, because the index type of Something_Array is Integer. Within the generic, Something is not an integer type, so this test should always return False. Presumably you want to check if Current_State is equal to one of the components of Final. To do that, you'll have to search Final. If Final is sorted, you can use a binary search; otherwise, you'll have to use a linear search. Your construct indicates that you do not understand booleans. If you could use the test you coded, you should have written return Current_State in Final'range; -- Jeff Carter "I blow my nose on you." Monty Python & the Holy Grail 03