How can I combine
list1={{x1,y1},{x2,y2},{x3,y3}}
and
list2={{x4,y4},{x5,y5}}
to
list={{x1,y1},{x2,y2},{x3,y3},{x4,y4},{x5,y5}}
?
|
How can I combine
and
to
? |
|||||||
|
|
You need
sometimes you would choose :
The latter doesn't include duplicates, as the first approach could, if some of elements in Edit It should be emphasized that since for small lists different approaches (pointed out in the other answers) are elegant and quite satisfactory, however for big lists
We can see that |
|||||||||||||
|
|
Since there's always more than one way to do things in Mathematica, here's another alternative:
The above uses infix notation, which might be a little hard to grok at first, but can make the code very readable for functions that take 2 arguments and have descriptive names. For comparison, here is the same expression written in 3 other forms:
|
|||||||||||||||||||||
|
|
And another:
|
|||||||||||||||||
|