comp.lang.ada
 help / color / mirror / Atom feed
From: Trish Cayetano <trishacayetano@gmail.com>
Subject: Re: How to check if letters are in a string?
Date: Sat, 18 Jul 2015 05:48:53 -0700 (PDT)
Date: 2015-07-18T05:48:53-07:00	[thread overview]
Message-ID: <4b621d18-91e2-4596-b064-cd7727ab12f7@googlegroups.com> (raw)
In-Reply-To: <moddin$20u$1@dont-email.me>

On Saturday, July 18, 2015 at 7:35:13 PM UTC+8, björn lundin wrote:
> Looks like I managed to mail this to the op instead of post it to c.l.a ...
> 
> 
> On 2015-07-18 11:00, Trish Cayetano wrote:
> > Is there another way how to check if (exact number of) letters are in
> a string?
> > Thank you very much!
> 
> declare
>   My_Letters: string := "HID"
>   My_String: string := "HIDDEN"
>   Is_In_String : boolean := False;
> begin
>   for L in My_Letters'range loop
>     Is_In_String := False;
>     for S in My_String'range loop
>       if My_Letters(L) = My_String(S) then
>         Is_In_String := True;
>         My_String(S) := ' '; --set to space, so letter is not reused
>         exit; -- inner loop
>       end if;
>     end loop;
>     exit when not Is_In_String;
>   end loop;
>   Text_io.put_Line("Is_In_String = "& Is_In_String'Img);
> end;
> 
> 
> 
> not compiled, not tested but the spirit of it
> should do what you want
> 
> -- -- Björn
> 
> -- 
> --
> Björn

Thank you Nasser and Björn!
Björn nailed it!

You are one genius, Björn! It's working fine after a few tweaks (really minor like adding Ada and adding packages). Thank you so much!

      reply	other threads:[~2015-07-18 12:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-18  9:00 How to check if letters are in a string? Trish Cayetano
2015-07-18 10:23 ` Nasser M. Abbasi
2015-07-18 10:52   ` Trish Cayetano
2015-07-18 11:07   ` Simon Clubley
2015-07-18 11:36 ` Björn Lundin
2015-07-18 12:48   ` Trish Cayetano [this message]
replies disabled

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