Re: Joining 2D arrays
- To: mathgroup at smc.vnet.net
- Subject: [mg49152] Re: Joining 2D arrays
- From: Jonathan Greenberg <greenberg at ucdavis.edu>
- Date: Mon, 5 Jul 2004 04:54:37 -0400 (EDT)
- References: <cc2uns$5iv$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Thanks to all who answered! Below are the responses I got:
***
Join[A,B]
***
That essentially depends on how you get at your tables. If you have them
available altogether in a single List, then just Apply Join (see Help >
Join, Apply). It will then take you a second or two (or less), but avoid
building up your database incrementally: that will take you the day.
See also (Help > Reep, Sow).
***
Hello !
Several possibilities...
Here two of them (in your example, modified to see the ordering problem)
A={{1,2},{8,9},{5,6}}
B={{6,7},{3,4},{10,11},{12,13}}
Join[A,B]
{{1,2},{8,9},{5,6},{6,7},{3,4},{10,11},{12,13}}
Flatten[{A,B},1]
{{1,2},{8,9},{5,6},{6,7},{3,4},{10,11},{12,13}}
You could also use Union[A,B], but in this case, the ordrer will be
re-arranged :
Union[A,B]
{{1,2},{3,4},{5,6},{6,7},{8,9},{10,11},{12,13}}
***
Following should work to join two lists:
Join[A,B] or
Append[A,B]
***
--j
On 7/1/04 11:18 PM, in article cc2uns$5iv$1 at smc.vnet.net, "Jonathan
Greenberg" <greenberg at ucdavis.edu> wrote:
> This is a total newbie question, but if I have two table of a fixed number
> of columns and an arbitrary number of rows, whats the easiest/most efficient
> way to join them together (basically, how do I add entries to a "database"
> in Mathematica) -- that database will eventually be perhaps > 1,000,000
> entries long...
>
> A={{1,2},{3,4},{5,6}}
> B={{6,7},{8,9},{10,11},{12,13}}
>
> I want:
>
> {{1,2},{3,4},{5,6},{6,7},{8,9},{10,11},{12,13}}
>
> --j
>