Re: Parsing challenge to reduce blanks



"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, 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)

Obviously this can be achieved without introducing further
executable statements.

--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end


.