Re: adding string arrays together

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon, 25 May 2009 09:31:21 -0600

Not sure of the question.

If all arr[1-4] are the same size then
   big_array = ndtooned( (/arr1,arr2,arr3,arr4/) )

-----

If all are different sizes ... *untested*

function combine(arr1[*]:string, arr2[*]:string \
                 ,arr3[*]:string, arr4[*]:string )
local N1, N2, N3, N4, NN, nStrt, nLast, big
begin
   N1 = dimsizes(arr1)
   N2 = dimsizes(arr2)
   N3 = dimsizes(arr3)
   N4 = dimsizes(arr4)
   NN = N1 + N2 + N3 + N4

   big = new (NN,"string")
   nStrt= 0
   nLast= N1-1
   big(nStrt:nLast) = arr1

   nStrt = nLast+1
   nLast = nStrt+N2-1
   big(nStrt:nLast) = arr2

   nStrt = nLast+1
   nLast = nStrt+N3-1
   big(nStrt:nLast) = arr3

   nStrt = nLast+1
   nLast = nStrt+N4-1
   big(nStrt:nLast) = arr4

   return(big)
end

   big_array = combine(arr1, arr2, arr3, arr4)

Good Luck

Joe Grim wrote:
> Hi,
>
> I know there has to be an easy way to do this, but I haven't been able
> to find it after searching for a half hour on the NCL website. I want
> to add the contents of 4 1D string arrays into a single array, so that
> the final array holds all the strings from the 4 separate arrays. I
> have tried the following, but none of these work:
> big_array = arr1 + arr2 + arr3 + arr4
> big_array = (arr1,arr2,arr3,arr4)
> big_array = (/arr1,arr2,arr3,arr4/)
>
> Could you tell me how to do this?
>
> Thanks!
>
> Joe Grim
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon May 25 2009 - 09:31:21 MDT

This archive was generated by hypermail 2.2.0 : Tue May 26 2009 - 10:17:16 MDT