J
Joshua Muheim
Hi all
What's the easiest way to merge two arrays?
Thanks a lot,
Josh
What's the easiest way to merge two arrays?
Thanks a lot,
Josh
What's the easiest way to merge two arrays?
Joshua said:This already anwers my question, thank you.
array1 =3D [1,2,4,6]
array2 =3D [1,3,5,6]
Is there an easy way for doing this?
array1 ?? array2 =3D [1,6] # Only add entries that occur in both arrays
array1 ?? array2 =3D [2,3,4,5] # Only add entries that occur in one of
both arrays
Joshua Muheim said:array1 = [1,2,4,6]
array2 = [1,3,5,6]
array1 ?? array2 = [1,6] # Only add entries that occur in both arrays
array1 ?? array2 = [2,3,4,5] # Only add entries that occur in one of
both arrays
your arrays.
Note these operators always make a new array for a result, they may
not be suitable when both your arrays are too large, though
YANAGAWA said:In Message-Id: <[email protected]>
Joshua Muheim said:array1 = [1,2,4,6]
array2 = [1,3,5,6]
array1 ?? array2 = [1,6] # Only add entries that occur in both arrays
array1 ?? array2 = [2,3,4,5] # Only add entries that occur in one of
both arrays
For former Array#& can be used if there're no duplicated elements in
your arrays. For latter, hmm, I can't remember no one methods but you
can (array1|array2)-(array1&array2), on same assumption.
Note these operators always make a new array for a result, they may
not be suitable when both your arrays are too large, though
--
Joshua Muheim said:Hrm I don't really got this... Where do I have to put the references
(array1, array2) for this?
Thanks for the hint. But they don't create clones of the objects in the
arrays, they just copy the references, right?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.