comp.lang.ada
 help / color / mirror / Atom feed
From: Rod Kay <rodakay5@gmail.com>
Subject: Re: Ok - WHAT are those "Maps.Identity" things ???
Date: Wed, 5 Jan 2022 16:49:51 +1100	[thread overview]
Message-ID: <sr3bi3$fu2$1@dont-email.me> (raw)
In-Reply-To: <DpqdnRjI8_ercUn8nZ2dnUU7-UnNnZ2d@earthlink.com>

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,<something>,<something-identity>)
> 
> 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.

  reply	other threads:[~2022-01-05  5:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-05  0:54 Ok - WHAT are those "Maps.Identity" things ??? 1.AAC0831
2022-01-05  5:49 ` Rod Kay [this message]
2022-01-07  2:31   ` 1.AAC0832
2022-01-07  3:39     ` Gautier write-only address
2022-01-07  4:14     ` Randy Brukardt
2022-01-10  5:13       ` 1.AAC0832
2022-01-10 10:19         ` Marius Amado-Alves
2022-01-11  5:20           ` 1.AAC0832
2022-01-07 11:48     ` G.B.
2022-01-10  4:49       ` 1.AAC0832
2022-01-05 13:01 ` Jeffrey R.Carter
2022-01-07  2:41   ` 1.AAC0832
2022-01-07  9:49     ` Jeffrey R.Carter
2022-01-10  4:46       ` 1.AAC0832
2022-01-10 15:05         ` Simon Wright
2022-01-11  5:17           ` 1.AAC0832
2022-01-11 11:33             ` Niklas Holsti
2022-01-12  4:22               ` 1.AAC0832
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox