Specific list manipulationImplementing a function which generalizes the merging step in merge sortWhat is the...

Tikz/Pgf - Surf plot with smooth color transition

Rigorous justification for non-relativistic QM perturbation theory assumptions?

Is practicing on a digital piano harmful to an experienced piano player?

smartctl reports overall health test as passed but the tests failed?

Is it really OK to use "because of"?

"Starve to death" Vs. "Starve to the point of death"

Why is Shelob considered evil?

Is there a way to pause a running process on Linux systems and resume later?

What can I do to encourage my players to use their consumables?

Why might frozen potatoes require a hechsher?

Identical projects by students at two different colleges: still plagiarism?

Why do objects rebound after hitting the ground?

Buying a "Used" Router

Homeostasis logic/math problem

Calculating the strength of an ionic bond that contains poly-atomic ions

How do I avoid the "chosen hero" feeling?

How can I differentiate duration vs starting time

How can I handle players killing my NPC outside of combat?

Other than edits for international editions, did Harry Potter and the Philosopher's Stone receive errata?

Why is it that Bernie Sanders is always called a "socialist"?

How to not let the Identify spell spoil everything?

Do we still track damage on indestructible creatures?

Are all power cords made equal?

What is an efficient way to digitize a family photo collection?



Specific list manipulation


Implementing a function which generalizes the merging step in merge sortWhat is the correct way to conditionally add elements to lists?How to create a Table of Tables with indexed variablesDealing with a huge datasetThreading elements over corresponding elements in the second listPick the maximum element of each nested listFinding the most common n-tuples of a list of lists where order does not matterGet sublists by pattern?Can a simple Part expression produce a list of elements from nested lists?Interpolating and plotting from a list













2












$begingroup$


Suppose I have two lists each of different size, e.g toy case ListX = {x1,x2,x3} and ListY = {y1,y2} and all possible combinations of elements give rise to an element in another list ListZ = {z1,z2,z3,z4,z5,z6} of dimension dim(ListX) x dim(ListY), i.e the tuple (x1,y1) is associated with z1, say.



How to merge all three lists such that I obtain the following combined list?



{{{x1,y1},z1}, {{x1,y2},z2}, {{x2,y1},z3}, {{x2,y2},z4}, {{x3,y1},z5},{{x3,y2},z6}}



I've tried nested tables but I always generate additional items that I don't want. The actual lists I'm dealing with are of dimension O(50) such that the equivalent of ListZ is of dimension O(2500).










share|improve this question









$endgroup$

















    2












    $begingroup$


    Suppose I have two lists each of different size, e.g toy case ListX = {x1,x2,x3} and ListY = {y1,y2} and all possible combinations of elements give rise to an element in another list ListZ = {z1,z2,z3,z4,z5,z6} of dimension dim(ListX) x dim(ListY), i.e the tuple (x1,y1) is associated with z1, say.



    How to merge all three lists such that I obtain the following combined list?



    {{{x1,y1},z1}, {{x1,y2},z2}, {{x2,y1},z3}, {{x2,y2},z4}, {{x3,y1},z5},{{x3,y2},z6}}



    I've tried nested tables but I always generate additional items that I don't want. The actual lists I'm dealing with are of dimension O(50) such that the equivalent of ListZ is of dimension O(2500).










    share|improve this question









    $endgroup$















      2












      2








      2





      $begingroup$


      Suppose I have two lists each of different size, e.g toy case ListX = {x1,x2,x3} and ListY = {y1,y2} and all possible combinations of elements give rise to an element in another list ListZ = {z1,z2,z3,z4,z5,z6} of dimension dim(ListX) x dim(ListY), i.e the tuple (x1,y1) is associated with z1, say.



      How to merge all three lists such that I obtain the following combined list?



      {{{x1,y1},z1}, {{x1,y2},z2}, {{x2,y1},z3}, {{x2,y2},z4}, {{x3,y1},z5},{{x3,y2},z6}}



      I've tried nested tables but I always generate additional items that I don't want. The actual lists I'm dealing with are of dimension O(50) such that the equivalent of ListZ is of dimension O(2500).










      share|improve this question









      $endgroup$




      Suppose I have two lists each of different size, e.g toy case ListX = {x1,x2,x3} and ListY = {y1,y2} and all possible combinations of elements give rise to an element in another list ListZ = {z1,z2,z3,z4,z5,z6} of dimension dim(ListX) x dim(ListY), i.e the tuple (x1,y1) is associated with z1, say.



      How to merge all three lists such that I obtain the following combined list?



      {{{x1,y1},z1}, {{x1,y2},z2}, {{x2,y1},z3}, {{x2,y2},z4}, {{x3,y1},z5},{{x3,y2},z6}}



      I've tried nested tables but I always generate additional items that I don't want. The actual lists I'm dealing with are of dimension O(50) such that the equivalent of ListZ is of dimension O(2500).







      list-manipulation table array






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 3 hours ago









      CAFCAF

      255110




      255110






















          2 Answers
          2






          active

          oldest

          votes


















          3












          $begingroup$

          This seems to do what you are looking for:



          ListX = {x1, x2, x3};
          ListY = {y1, y2};
          ListZ = {z1, z2, z3, z4, z5, z6};
          Partition[Riffle[Flatten[Outer[List, ListX, ListY], 1], ListZ], 2]


          The Outer product gives all the pairs, but they are nested funny so you need to Flatten. Riffle does the interleaving of the Outer product with ListZ, and again it's not quite got your desired structure, but Partition fixes that.






          share|improve this answer









          $endgroup$





















            1












            $begingroup$

            Transpose@{Tuples@{ListX, ListY}, ListZ}





            share|improve this answer








            New contributor




            ukar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.






            $endgroup$









            • 1




              $begingroup$
              Very nice solution! You can also use Thread instead of Transpose:Thread@{Tuples@{ListX, ListY}, ListZ}
              $endgroup$
              – rmw
              2 hours ago










            • $begingroup$
              Yes. Thanks for reminding me that.
              $endgroup$
              – ukar
              10 mins ago











            Your Answer





            StackExchange.ifUsing("editor", function () {
            return StackExchange.using("mathjaxEditing", function () {
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            });
            });
            }, "mathjax-editing");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "387"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f192128%2fspecific-list-manipulation%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3












            $begingroup$

            This seems to do what you are looking for:



            ListX = {x1, x2, x3};
            ListY = {y1, y2};
            ListZ = {z1, z2, z3, z4, z5, z6};
            Partition[Riffle[Flatten[Outer[List, ListX, ListY], 1], ListZ], 2]


            The Outer product gives all the pairs, but they are nested funny so you need to Flatten. Riffle does the interleaving of the Outer product with ListZ, and again it's not quite got your desired structure, but Partition fixes that.






            share|improve this answer









            $endgroup$


















              3












              $begingroup$

              This seems to do what you are looking for:



              ListX = {x1, x2, x3};
              ListY = {y1, y2};
              ListZ = {z1, z2, z3, z4, z5, z6};
              Partition[Riffle[Flatten[Outer[List, ListX, ListY], 1], ListZ], 2]


              The Outer product gives all the pairs, but they are nested funny so you need to Flatten. Riffle does the interleaving of the Outer product with ListZ, and again it's not quite got your desired structure, but Partition fixes that.






              share|improve this answer









              $endgroup$
















                3












                3








                3





                $begingroup$

                This seems to do what you are looking for:



                ListX = {x1, x2, x3};
                ListY = {y1, y2};
                ListZ = {z1, z2, z3, z4, z5, z6};
                Partition[Riffle[Flatten[Outer[List, ListX, ListY], 1], ListZ], 2]


                The Outer product gives all the pairs, but they are nested funny so you need to Flatten. Riffle does the interleaving of the Outer product with ListZ, and again it's not quite got your desired structure, but Partition fixes that.






                share|improve this answer









                $endgroup$



                This seems to do what you are looking for:



                ListX = {x1, x2, x3};
                ListY = {y1, y2};
                ListZ = {z1, z2, z3, z4, z5, z6};
                Partition[Riffle[Flatten[Outer[List, ListX, ListY], 1], ListZ], 2]


                The Outer product gives all the pairs, but they are nested funny so you need to Flatten. Riffle does the interleaving of the Outer product with ListZ, and again it's not quite got your desired structure, but Partition fixes that.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 3 hours ago









                bill sbill s

                53.6k376152




                53.6k376152























                    1












                    $begingroup$

                    Transpose@{Tuples@{ListX, ListY}, ListZ}





                    share|improve this answer








                    New contributor




                    ukar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.






                    $endgroup$









                    • 1




                      $begingroup$
                      Very nice solution! You can also use Thread instead of Transpose:Thread@{Tuples@{ListX, ListY}, ListZ}
                      $endgroup$
                      – rmw
                      2 hours ago










                    • $begingroup$
                      Yes. Thanks for reminding me that.
                      $endgroup$
                      – ukar
                      10 mins ago
















                    1












                    $begingroup$

                    Transpose@{Tuples@{ListX, ListY}, ListZ}





                    share|improve this answer








                    New contributor




                    ukar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.






                    $endgroup$









                    • 1




                      $begingroup$
                      Very nice solution! You can also use Thread instead of Transpose:Thread@{Tuples@{ListX, ListY}, ListZ}
                      $endgroup$
                      – rmw
                      2 hours ago










                    • $begingroup$
                      Yes. Thanks for reminding me that.
                      $endgroup$
                      – ukar
                      10 mins ago














                    1












                    1








                    1





                    $begingroup$

                    Transpose@{Tuples@{ListX, ListY}, ListZ}





                    share|improve this answer








                    New contributor




                    ukar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.






                    $endgroup$



                    Transpose@{Tuples@{ListX, ListY}, ListZ}






                    share|improve this answer








                    New contributor




                    ukar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.









                    share|improve this answer



                    share|improve this answer






                    New contributor




                    ukar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.









                    answered 3 hours ago









                    ukarukar

                    191




                    191




                    New contributor




                    ukar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.





                    New contributor





                    ukar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.






                    ukar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.








                    • 1




                      $begingroup$
                      Very nice solution! You can also use Thread instead of Transpose:Thread@{Tuples@{ListX, ListY}, ListZ}
                      $endgroup$
                      – rmw
                      2 hours ago










                    • $begingroup$
                      Yes. Thanks for reminding me that.
                      $endgroup$
                      – ukar
                      10 mins ago














                    • 1




                      $begingroup$
                      Very nice solution! You can also use Thread instead of Transpose:Thread@{Tuples@{ListX, ListY}, ListZ}
                      $endgroup$
                      – rmw
                      2 hours ago










                    • $begingroup$
                      Yes. Thanks for reminding me that.
                      $endgroup$
                      – ukar
                      10 mins ago








                    1




                    1




                    $begingroup$
                    Very nice solution! You can also use Thread instead of Transpose:Thread@{Tuples@{ListX, ListY}, ListZ}
                    $endgroup$
                    – rmw
                    2 hours ago




                    $begingroup$
                    Very nice solution! You can also use Thread instead of Transpose:Thread@{Tuples@{ListX, ListY}, ListZ}
                    $endgroup$
                    – rmw
                    2 hours ago












                    $begingroup$
                    Yes. Thanks for reminding me that.
                    $endgroup$
                    – ukar
                    10 mins ago




                    $begingroup$
                    Yes. Thanks for reminding me that.
                    $endgroup$
                    – ukar
                    10 mins ago


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Mathematica Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    Use MathJax to format equations. MathJax reference.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f192128%2fspecific-list-manipulation%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Szabolcs (Ungheria) Altri progetti | Menu di navigazione48°10′14.56″N 21°29′33.14″E /...

                    Discografia di Klaus Schulze Indice Album in studio | Album dal vivo | Singoli | Antologie | Colonne...

                    How to make inet_server_addr() return localhost in spite of ::1/128RETURN NEXT in Postgres FunctionConnect to...