Re: Looking for the best "JOIN"
- Posted by Derek Parnell <ddparnell at bigpond.com> Oct 22, 2001
- 392 views
----- Original Message ----- From: <euman at bellsouth.net> To: "EUforum" <EUforum at topica.com> Subject: Looking for the best "JOIN" > > Im looking for the best JOIN method. > > Heres what I have: {"str1","str2","str3"} > > Heres what I want: "str1str2str3" > > No slow ideas please>>>> Okay, I'll bite. --------------------- global function joinStrings(sequence s) integer l,a,b sequence t if length(s) = 0 then return s end if l = 0 for i = 1 to length(s) do l += length(s[i]) end for t = repeat(0, l) a = 1 for i = 1 to length(s) do b = a + length(s[i]) - 1 t[a..b] = s[i] a = b + 1 end for return t end function -- Test code -- constant words = {"abc","defghi","jklmnopqr","","st","u","vwxyz"} atom e sequence k integer x x = 0 e = time() + 10 while e >= time() do x += 1 k =joinStrings(words) end while printf(1, "%d interations in 10 seconds\n", x) --------------------- Derek