Path: utzoo!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!isidev.UUCP!nowlin From: nowlin@isidev.UUCP Newsgroups: comp.lang.icon Subject: Re: terrible code (2) Message-ID: <9103181558.AA20389@uunet.uu.net> Date: 18 Mar 91 15:58:25 GMT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The Internet Lines: 46 I figured out what I was doing wrong and got the program originally posted to work. I came up with a solution that got the same answer for my test data. Is this a possible solution to what you were trying to do? Notice I just borrowed the argument processing code from the original anystr() procedure for my longstr() procedure: procedure main(args) l := ["th","that ","not close","tha","that b","t"] s := "that begins this string" #write(anystr(l,s)) write(longstr(l,s)) end procedure longstr(l,s,i,j) ##### borrowed ##### /s := &subject if \i then { if i < 1 then i := *s + (i+1) } else i := \&pos | 1 if \j then { if j < 1 then j := *s + (j+1) } else j := *s+1 ##### borrowed ##### m := 0 while *(p := (s ? =!l)) > m do m := *p return m + 1 end I didn't include the original posted code here but you can add it to this program and test the two solutions together. I haven't a clue which is faster but this one is somewhat shorter. +-------------------------------------------------------------------------+ | --- --- | | | S | Iconic Software, Inc. - Jerry Nowlin - uunet!isidev!nowlin | | --- --- | +-------------------------------------------------------------------------+