Suppose I have an array of differently shaped strings, such as this:

   a =: 'foo';'z';'quux'

Now I'd like to concatenate its open elements, to get 'foozquux'.
The problem here is that I can't just open the array and do something
after that, as that would bring the strings to a common size.  Thus,
I have to do this:

   >,&.>/ a

There's however a problem with this.  It's very slow for large
arrays:

   10(6!:2) '>,&.>/ ,1000 1$ a'
0.0014051
   10(6!:2) '>,&.>/ ,10000 1$ a'
0.0836255
   10(6!:2) '>,&.>/ ,100000 1$ a'
26.6436

It appears that the slowdown is quadratic, which may be because the string
gets copied after each string is concatenated to it.

I'd like to see a faster solution for this, possibly using special codes.

ambrus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to