Re: Parsing challenge to reduce blanks
- From: "James Van Buskirk" <not_valid@xxxxxxxxxxx>
- Date: Tue, 2 Aug 2005 11:01:05 -0600
"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
.
- Follow-Ups:
- Re: Parsing challenge to reduce blanks
- From: David Frank
- Re: Parsing challenge to reduce blanks
- References:
- Parsing challenge to reduce blanks
- From: David Frank
- Re: Parsing challenge to reduce blanks
- From: David Frank
- Parsing challenge to reduce blanks
- Prev by Date: Re: Parsing challenge to reduce blanks
- Next by Date: Re: Spaghetti code
- Previous by thread: Re: Parsing challenge to reduce blanks
- Next by thread: Re: Parsing challenge to reduce blanks
- Index(es):