From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,NICE_REPLY_A,URI_TRY_3LD autolearn=no autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Rod Kay Newsgroups: comp.lang.ada Subject: Re: Ok - WHAT are those "Maps.Identity" things ??? Date: Wed, 5 Jan 2022 16:49:51 +1100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 5 Jan 2022 05:49:56 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="8e2cbfa1b5b2277c2f4af20f4b51d6b5"; logging-data="16322"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19sj4NZB4EGpREVBhob/dXEagJNbHpRKgs=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 Cancel-Lock: sha1:+06PLp9JOrtNNxw2Ygkwt7e95uA= In-Reply-To: Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:63341 List-Id: On 5/1/22 11:54 am, 1.AAC0831 wrote: > > Ok ... ADA online documentation is POOR. Lots of > definitions, often NO practical examples of even > the simplest things. You'd expect more for an > "official DOD" language. > With a duckduckgo search on "ada string index", the first hit is ... https://learn.adacore.com/courses/intro-to-ada/chapters/standard_library_strings.html ... which provides a simple example of the 'Index' function. > Problem : I want to find out if/where a substring > is in another string (lets assume unbounded strings). > > The docs say to use Index(source,substr,,) > > Well, I can guess what the first two are. The third probably > is "forward" or maybe '1' for "start at first'. However all > examples of Index have some kind of mapping param for #4 > and I've used every search engine and CANNOT figure out what > goes in there. https://www.adaic.org/resources/add_content/standards/05rm/html/RM-A-4-2.html https://www.adaic.org/resources/add_content/standards/05rm/html/RM-A-4-3.html In many/most cases, the default parameters for 'Mapping' are fine. > All that works fine. The very last thing I wanted to > add was a "is substring in string" function - might > return a boolean, but I might cheat and return a real > with the listindex .point. position-in-str sort of format. > function Contains (Source : in String; Pattern : in String) return Boolean is use Ada.Strings.Fixed; begin return Index (Source, Pattern) /= 0; end Contains; In summary, Ada is one of the the best documented languages in existence. Consider the excellent 'Language Reference Manual', the 'Ada Rationale's and the 'Ada Quality and Style Guide's. Furthermore the resources at 'https://learn.adacore.com' and 'https://www.adacore.com/gems' provide many examples of best practices in specific areas of interest. Finally, forums such as 'comp.lang.ada' and the '#ada' irc channel on the 'irc.libera.chat' server are great places to quickly find answers. Regards.