dscargo@CIM-VAX.HONEYWELL.COM ("DAVE CARGO") (09/21/89)
Richard Goerwitz corrected my problem with the Icon syntax and
proposed his solution to the capitalization problem. I tried it and it
worked, but I got currious about performance. When I timed his
solution with a corrected varient of one of mine,I discovered that
the string scanning approach takes more time (about half again
more as revealed by timing tests on Icon 7.0 for VMS.
Richard's solution:
procedure capline(word, line)
line2 := ""
line ? {
while line2 ||:= tab(find(word))
do line2 ||:= map(=word,&lcase,&ucase)
line2 ||:= tab(0)
}
return line2
end
my corrected and modified solution:
procedure capline(word, line)
line2 := copy(line)
every line2[find(word, line)+:*word] := map(word, &lcase, &ucase)
return line2
end
I think my solution is faster because it creates fewer tempory
variables and does fewer operations.