Re: Sunday string puzzler




"Walter Spector" <w6ws_xthisoutx@xxxxxxxxxxxxx> wrote in message
news:45571D3B.E74D1A52@xxxxxxxxxxxxxxxx
David Frank wrote:
... what 1
statement
may be plugged in below?

! -----------------------
program extract_vowels ! from string
character(80) :: string = 'the quick brown fox', extract = ' '
character :: vowels(5) = ['a','e','i','o','u']

do i = 1,len_trim(string)

extract(len_trim (extract)+1:) = &
merge (string(i:i), ' ', any (string(i:i) == vowels))

end do
write (*,*) trim(extract) ! outputs euioo
end program

Note that a slightly shorter version of the above would use the SCAN
intrinsic. But 'vowels' would need to be in a single string - not in an
array.

Next: Since David insists the above fit in a single statement, the code
has
a 'hidden' bug in it. What is the bug?

W.

Beats me,
btw, there is a true 1 statement solution (no encompassing do loop
statements),
can someone post it?


.



Relevant Pages

  • Re: Sunday string puzzler
    ... David Frank wrote: ... But 'vowels' would need to be in a single string - not in an ... a 'hidden' bug in it. ...
    (comp.lang.fortran)
  • Re: [EGN] Variable hoisting
    ... Re: The Data Quality Act ... In the process I found a SERIOUS bug in the C code. ... CS> The allocated string has no room for the trailing nul. ... An mature adult programmer would have taken it for what ...
    (comp.programming)
  • Re: [PATCH] [PNP] modalias sysfs export
    ... let the device table match one of these id's in that single string: ... We may loose the ability to support new buses ... schemes without depreciating existing kernel interfaces or parsing strings ...
    (Linux-Kernel)
  • Re: Comment on trim string function please
    ... I think you have a bug. ... but does it fly past the terminating null character? ... initial space scan) then this writes outside the string. ... ASIDE FROM THE CAST "ISSUES", ...
    (comp.lang.c)
  • Weekly Python Patch/Bug Summary
    ... Patch / Bug Summary ... most missing from Windows distribution ... http://python.org/sf/1541585 closed by gbrandl ... Compiler command percent-sign causes format string error ...
    (comp.lang.python)