Re: Looking for the best "JOIN"
- Posted by euphoria at carlw.legend.uk.com Oct 22, 2001
- 382 views
Euman wrote: > Im looking for the best JOIN method. > > Heres what I have: {"str1","str2","str3"} > > Heres what I want: "str1str2str3" function join(sequence s) -- this is the way most people would do it sequence j if not length(s) then return s end if j = {} for i = 1 to length(s) j &= s[i] end for return j end function ...or...: function join2(sequence s) -- this shouldn't be any faster but who knows? sequence j integer mid, len len = length(s) if not len then return s elsif len = 1 then return s[1] elsif len = 2 then return s[1]&s[2] end if mid = floor(len/2) return join2(s[1..mid])&join2(s[mid+1..len]) end function Carl