Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!CIM-VAX.HONEYWELL.COM!dscargo From: dscargo@CIM-VAX.HONEYWELL.COM ("DAVE CARGO") Newsgroups: comp.lang.icon Subject: string scanning vs. assignment Message-ID: <8909201614.AA16660@megaron.arizona.edu> Date: 20 Sep 89 17:01:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The Internet Lines: 29 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.