Re: Parsing challenge to reduce blanks




"James Van Buskirk" <not_valid@xxxxxxxxxxx> wrote in message
news:LtSdnYxDq_5JO3LfRVn-ow@xxxxxxxxxxxxxx
> "David Frank" <dave_frank@xxxxxxxxxxx> wrote in message
> news:neFHe.12621$oZ.9766@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
>> function reduce_blanks(line) result (outline)
>> character(*) :: line
>> character(len(line)) :: outline
>> character :: a(len(line))
>
>> a = transfer(line,a)
>> forall (i=1:size(a)-1, a(i)==' '.and.a(i+1)==' ') a(i) = char(0)
>> outline = transfer(pack(a,a /= char(0), spread(' ',1,size(a))), outline)
>
>> end function reduce_blanks
>
> Your solution is fairly close to mine,

If you say so, altho I didnt see my technique of 1st marking the repeats
with a forall and then
discarding them with a pack that has a spread to fill in the trailing blanks
in your code.
Didnt you say your solution has a problem with exact size text in line?


> spread out over more statements. It suffers the same problem, though.
> Compressing
> repeated spaces into one requires that
>
> len(reduce_blanks('xxx'//repeat(' ',n))) = merge(4,3,n > 0)
>

Dont be so obtuse, show me a sample line that wont get properly reduced
because
my solution "suffers the same problem" as yours.

> Obviously this can be achieved without introducing further
> executable statements.
>

Well first show me my problem and I will try to fix it..


.