Re: do while: most elegant or efficient

beliavsky_at_aol.com
Date: 01/24/05


Date: 24 Jan 2005 03:55:04 -0800

In your code, perhaps the LHS of

a = 'bcdef'

should have been variable c, which is otherwise not set. One can find
the first occurrence of 'a' in string c with

n = index(c,"a")

The reason the first code may not work is that according to the Fortran
standard, the second conditional involving c(n:n) may be evaluated
before the first one is, resulting in trying to access an out-of-bound
element of c. If there were no "index" function, I would probably use a
DO loop with an EXIT, although I don't know if it is faster.



Relevant Pages

  • Re: Get the path and namefile in run time
    ... function Get_Path_Only return String; ... -- This returns the first N characters of the program name. ... end loop; ...
    (comp.lang.ada)
  • Re: Parse String
    ... it picking up substrings beginning with 'f' followed by hyphens, ... Function gnaf(s As String) As Variant ... Exit Do 'inner Do ... Loop ...
    (microsoft.public.excel.programming)
  • Re: Newbie needs help
    ... You want to exit the loop when the user types ... void ParseLine (const string& cInput, ...
    (comp.lang.cpp)
  • Avoiding side effects
    ... function Strip (Remove_This: in String) return String ... The main program is then merely a loop where I alternate between ... exit when EOF_Reached; ...
    (comp.lang.ada)
  • Re: Ada Shootout program for K-Nucleotide (patches)
    ... - a loop reading input lines into an ... ubounded string replaces the recursive String "&"ing ... The following Getline has left me unconvinced. ... exit when Last = Item'Last; ...
    (comp.lang.ada)