Re: Sunday string puzzler
- From: "David Frank" <dave_frank@xxxxxxxxxxx>
- Date: Sun, 12 Nov 2006 16:10:31 -0500
"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?
.
- Follow-Ups:
- Re: Sunday string puzzler
- From: David Frank
- Re: Sunday string puzzler
- References:
- Sunday string puzzler
- From: David Frank
- Re: Sunday string puzzler
- From: Walter Spector
- Sunday string puzzler
- Prev by Date: Big Optical Design Program in Fortran
- Next by Date: Re: what's wrong with the output?
- Previous by thread: Re: Sunday string puzzler
- Next by thread: Re: Sunday string puzzler
- Index(es):
Relevant Pages
|