What is the identity for Tuples?Duplicate TuplesSelecting from a list returned by TuplesSelect elements in a list of tuples of quaternions that satisfy a conditionTuples of elements from list excluding anything with repeated valuesDelete duplicates in tuples

I have just 4 hours a month to security check a cloud based application - How to use my time?

Undefined control sequence error after TeX Live update

Change date format with sed or awk in file

How to get a large amount of cash abroad if a debit card stops working?

JPEG with transparent background

After upgrading Xcode 11.2 from Xcode 11.1, app crashes due to _UITextLayoutView

Replacing 2-prong outlets in basement - existing wiring has two hot wires, one neutral?

At The Square Brackets

Pigeon Hole Principle (most probably)

Is it possible to be admitted to CS PhD programs (in US) with scholarship at age 18?

What is the difference between money and currency?

Are there any galaxies visible in the night sky around the Orion constellation?

Is there a heuristic approach to the MILP problem?

I have been accused of copying two lab reports from the previous year even though I had done everything by myself

What does it mean by "commercial support available" for an open-source platform?

Isn't LaTeX a complete software for producing books?

Why is weak Kőnig's lemma weaker than Kőnig's lemma?

Is there any 24/7 store in Turku?

Mechanics to keep mobs and environment alive without using tons of memory?

Why is it possible to teach real numbers before even rigorously defining them?

How to enable Double-Tap to Drag in Mac OS X Catalina?

Did Catherine the Great really call for the abolition of serfdom?

How should a leader behave when they miss deadlines themselves?

1 kHz clock over long wire



What is the identity for Tuples?


Duplicate TuplesSelecting from a list returned by TuplesSelect elements in a list of tuples of quaternions that satisfy a conditionTuples of elements from list excluding anything with repeated valuesDelete duplicates in tuples






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;

.everyonelovesstackoverflowposition:absolute;height:1px;width:1px;opacity:0;top:0;left:0;pointer-events:none;








5














$begingroup$


My question is, what list p in the following statement returns the list q?



Tuples[p,q]


If we think of Tuples as a binary operator then p would be the identity for Tuples.



I thought an empty list would work, but evaluating the following



Tuples[,1,2,3]


gives instead of 1,2,3 or 1,2,3 as I had hoped.



The following doesn't work either:



Tuples[[EmptySet],1,2,3]


Certainly, I could write a function like the following



altTuples[p_List,q_List]:= If[Length[p]==0,q,Tuples[p,q]


That does exactly what I want, but I want to know if I'm missing something. Is there in fact an identity for Tuples? Is there a way to do what I want with Outer? I've tried the obvious solutions with no luck.










share|improve this question












$endgroup$










  • 1




    $begingroup$
    How do you want your altTuples[] to behave when the length of $p$ is not zero? For example altTuples[a, b, c, d, e, f] returns Tuples[a, b, c, d, e, f], probably not what you want.
    $endgroup$
    – mjw
    Jul 8 at 1:19










  • $begingroup$
    I corrected altTuples. Actually I want it to return Tuples[a, b, c, d, e, f]. I think Nothing is what I was looking for.
    $endgroup$
    – JAS
    Jul 8 at 23:27











  • $begingroup$
    What you have above is almost correct (up to a typo). Anyway seems to produce what you want. 'AltTuples[p,q]` gives the same output as Tuples[p,q] when the first argument is a list with non-zero length.
    $endgroup$
    – mjw
    Jul 8 at 23:36


















5














$begingroup$


My question is, what list p in the following statement returns the list q?



Tuples[p,q]


If we think of Tuples as a binary operator then p would be the identity for Tuples.



I thought an empty list would work, but evaluating the following



Tuples[,1,2,3]


gives instead of 1,2,3 or 1,2,3 as I had hoped.



The following doesn't work either:



Tuples[[EmptySet],1,2,3]


Certainly, I could write a function like the following



altTuples[p_List,q_List]:= If[Length[p]==0,q,Tuples[p,q]


That does exactly what I want, but I want to know if I'm missing something. Is there in fact an identity for Tuples? Is there a way to do what I want with Outer? I've tried the obvious solutions with no luck.










share|improve this question












$endgroup$










  • 1




    $begingroup$
    How do you want your altTuples[] to behave when the length of $p$ is not zero? For example altTuples[a, b, c, d, e, f] returns Tuples[a, b, c, d, e, f], probably not what you want.
    $endgroup$
    – mjw
    Jul 8 at 1:19










  • $begingroup$
    I corrected altTuples. Actually I want it to return Tuples[a, b, c, d, e, f]. I think Nothing is what I was looking for.
    $endgroup$
    – JAS
    Jul 8 at 23:27











  • $begingroup$
    What you have above is almost correct (up to a typo). Anyway seems to produce what you want. 'AltTuples[p,q]` gives the same output as Tuples[p,q] when the first argument is a list with non-zero length.
    $endgroup$
    – mjw
    Jul 8 at 23:36














5












5








5


1



$begingroup$


My question is, what list p in the following statement returns the list q?



Tuples[p,q]


If we think of Tuples as a binary operator then p would be the identity for Tuples.



I thought an empty list would work, but evaluating the following



Tuples[,1,2,3]


gives instead of 1,2,3 or 1,2,3 as I had hoped.



The following doesn't work either:



Tuples[[EmptySet],1,2,3]


Certainly, I could write a function like the following



altTuples[p_List,q_List]:= If[Length[p]==0,q,Tuples[p,q]


That does exactly what I want, but I want to know if I'm missing something. Is there in fact an identity for Tuples? Is there a way to do what I want with Outer? I've tried the obvious solutions with no luck.










share|improve this question












$endgroup$




My question is, what list p in the following statement returns the list q?



Tuples[p,q]


If we think of Tuples as a binary operator then p would be the identity for Tuples.



I thought an empty list would work, but evaluating the following



Tuples[,1,2,3]


gives instead of 1,2,3 or 1,2,3 as I had hoped.



The following doesn't work either:



Tuples[[EmptySet],1,2,3]


Certainly, I could write a function like the following



altTuples[p_List,q_List]:= If[Length[p]==0,q,Tuples[p,q]


That does exactly what I want, but I want to know if I'm missing something. Is there in fact an identity for Tuples? Is there a way to do what I want with Outer? I've tried the obvious solutions with no luck.







tuples






share|improve this question
















share|improve this question













share|improve this question




share|improve this question








edited Jul 8 at 23:25







JAS

















asked Jul 7 at 22:18









JASJAS

263 bronze badges




263 bronze badges










  • 1




    $begingroup$
    How do you want your altTuples[] to behave when the length of $p$ is not zero? For example altTuples[a, b, c, d, e, f] returns Tuples[a, b, c, d, e, f], probably not what you want.
    $endgroup$
    – mjw
    Jul 8 at 1:19










  • $begingroup$
    I corrected altTuples. Actually I want it to return Tuples[a, b, c, d, e, f]. I think Nothing is what I was looking for.
    $endgroup$
    – JAS
    Jul 8 at 23:27











  • $begingroup$
    What you have above is almost correct (up to a typo). Anyway seems to produce what you want. 'AltTuples[p,q]` gives the same output as Tuples[p,q] when the first argument is a list with non-zero length.
    $endgroup$
    – mjw
    Jul 8 at 23:36













  • 1




    $begingroup$
    How do you want your altTuples[] to behave when the length of $p$ is not zero? For example altTuples[a, b, c, d, e, f] returns Tuples[a, b, c, d, e, f], probably not what you want.
    $endgroup$
    – mjw
    Jul 8 at 1:19










  • $begingroup$
    I corrected altTuples. Actually I want it to return Tuples[a, b, c, d, e, f]. I think Nothing is what I was looking for.
    $endgroup$
    – JAS
    Jul 8 at 23:27











  • $begingroup$
    What you have above is almost correct (up to a typo). Anyway seems to produce what you want. 'AltTuples[p,q]` gives the same output as Tuples[p,q] when the first argument is a list with non-zero length.
    $endgroup$
    – mjw
    Jul 8 at 23:36








1




1




$begingroup$
How do you want your altTuples[] to behave when the length of $p$ is not zero? For example altTuples[a, b, c, d, e, f] returns Tuples[a, b, c, d, e, f], probably not what you want.
$endgroup$
– mjw
Jul 8 at 1:19




$begingroup$
How do you want your altTuples[] to behave when the length of $p$ is not zero? For example altTuples[a, b, c, d, e, f] returns Tuples[a, b, c, d, e, f], probably not what you want.
$endgroup$
– mjw
Jul 8 at 1:19












$begingroup$
I corrected altTuples. Actually I want it to return Tuples[a, b, c, d, e, f]. I think Nothing is what I was looking for.
$endgroup$
– JAS
Jul 8 at 23:27





$begingroup$
I corrected altTuples. Actually I want it to return Tuples[a, b, c, d, e, f]. I think Nothing is what I was looking for.
$endgroup$
– JAS
Jul 8 at 23:27













$begingroup$
What you have above is almost correct (up to a typo). Anyway seems to produce what you want. 'AltTuples[p,q]` gives the same output as Tuples[p,q] when the first argument is a list with non-zero length.
$endgroup$
– mjw
Jul 8 at 23:36





$begingroup$
What you have above is almost correct (up to a typo). Anyway seems to produce what you want. 'AltTuples[p,q]` gives the same output as Tuples[p,q] when the first argument is a list with non-zero length.
$endgroup$
– mjw
Jul 8 at 23:36











4 Answers
4






active

oldest

votes


















7
















$begingroup$

If 1,2,3 is fine, you can use Nothing:



Tuples[Nothing, 1, 2, 3]
(* 1, 2, 3 *)


If you want 1,2,3, you can Flatten the result, of course.






share|improve this answer










$endgroup$










  • 1




    $begingroup$
    Thank you, this does exactly what I need.
    $endgroup$
    – JAS
    Jul 8 at 23:20


















4
















$begingroup$

You can use Inactive[Sequence][] as identity like this:



Tuples[Inactive[Sequence][],q]//Activate



q







share|improve this answer










$endgroup$






















    4
















    $begingroup$

    Use TagSetDelayed to define a function that behaves as desired:



    ClearAll[iDentity]
    iDentity /: iDentity[___], a : __ := iDentity[a]
    iDentity /: Tuples[iDentity[a_]] := a

    Tuples[iDentity[], q]



    q




    Tuples[iDentity[blah], 1, 2, 3]



    1, 2, 3




    Alternatively, define your function altTuples with two signatures:



    ClearAll[altTuples]
    altTuples[tuplesIdentity ] := a
    altTuples[x_] := Tuples[x]

    altTuples[x, y, 1, 2]



    x, 1, x, 2, y, 1, y, 2




    altTuples[tuplesIdentity, 1, 2]



    1, 2




    altTuples[, 1, 2]



    1, 2







    share|improve this answer












    $endgroup$






















      0
















      $begingroup$

      I think this is what you want:



      altTuples[p_List, q_List] := If[Length[p] == 0, q, Tuples[p, q]]


      The statement



      altTuples[, d, e, f]


      returns



      d, e, f


      and



      altTuples[a, b, c, d, e, f]


      returns



      a, d, a, e, a, f, b, d, b, e, b, f, c, d, c, e, c, f





      share|improve this answer










      $endgroup$
















        Your Answer








        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/4.0/"u003ecc by-sa 4.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%2f201715%2fwhat-is-the-identity-for-tuples%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown


























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        7
















        $begingroup$

        If 1,2,3 is fine, you can use Nothing:



        Tuples[Nothing, 1, 2, 3]
        (* 1, 2, 3 *)


        If you want 1,2,3, you can Flatten the result, of course.






        share|improve this answer










        $endgroup$










        • 1




          $begingroup$
          Thank you, this does exactly what I need.
          $endgroup$
          – JAS
          Jul 8 at 23:20















        7
















        $begingroup$

        If 1,2,3 is fine, you can use Nothing:



        Tuples[Nothing, 1, 2, 3]
        (* 1, 2, 3 *)


        If you want 1,2,3, you can Flatten the result, of course.






        share|improve this answer










        $endgroup$










        • 1




          $begingroup$
          Thank you, this does exactly what I need.
          $endgroup$
          – JAS
          Jul 8 at 23:20













        7














        7










        7







        $begingroup$

        If 1,2,3 is fine, you can use Nothing:



        Tuples[Nothing, 1, 2, 3]
        (* 1, 2, 3 *)


        If you want 1,2,3, you can Flatten the result, of course.






        share|improve this answer










        $endgroup$



        If 1,2,3 is fine, you can use Nothing:



        Tuples[Nothing, 1, 2, 3]
        (* 1, 2, 3 *)


        If you want 1,2,3, you can Flatten the result, of course.







        share|improve this answer













        share|improve this answer




        share|improve this answer










        answered Jul 7 at 22:45









        AccidentalFourierTransformAccidentalFourierTransform

        7,0781 gold badge14 silver badges45 bronze badges




        7,0781 gold badge14 silver badges45 bronze badges










        • 1




          $begingroup$
          Thank you, this does exactly what I need.
          $endgroup$
          – JAS
          Jul 8 at 23:20












        • 1




          $begingroup$
          Thank you, this does exactly what I need.
          $endgroup$
          – JAS
          Jul 8 at 23:20







        1




        1




        $begingroup$
        Thank you, this does exactly what I need.
        $endgroup$
        – JAS
        Jul 8 at 23:20




        $begingroup$
        Thank you, this does exactly what I need.
        $endgroup$
        – JAS
        Jul 8 at 23:20













        4
















        $begingroup$

        You can use Inactive[Sequence][] as identity like this:



        Tuples[Inactive[Sequence][],q]//Activate



        q







        share|improve this answer










        $endgroup$



















          4
















          $begingroup$

          You can use Inactive[Sequence][] as identity like this:



          Tuples[Inactive[Sequence][],q]//Activate



          q







          share|improve this answer










          $endgroup$

















            4














            4










            4







            $begingroup$

            You can use Inactive[Sequence][] as identity like this:



            Tuples[Inactive[Sequence][],q]//Activate



            q







            share|improve this answer










            $endgroup$



            You can use Inactive[Sequence][] as identity like this:



            Tuples[Inactive[Sequence][],q]//Activate



            q








            share|improve this answer













            share|improve this answer




            share|improve this answer










            answered Jul 7 at 22:36









            Thies HeideckeThies Heidecke

            7,90426 silver badges40 bronze badges




            7,90426 silver badges40 bronze badges
























                4
















                $begingroup$

                Use TagSetDelayed to define a function that behaves as desired:



                ClearAll[iDentity]
                iDentity /: iDentity[___], a : __ := iDentity[a]
                iDentity /: Tuples[iDentity[a_]] := a

                Tuples[iDentity[], q]



                q




                Tuples[iDentity[blah], 1, 2, 3]



                1, 2, 3




                Alternatively, define your function altTuples with two signatures:



                ClearAll[altTuples]
                altTuples[tuplesIdentity ] := a
                altTuples[x_] := Tuples[x]

                altTuples[x, y, 1, 2]



                x, 1, x, 2, y, 1, y, 2




                altTuples[tuplesIdentity, 1, 2]



                1, 2




                altTuples[, 1, 2]



                1, 2







                share|improve this answer












                $endgroup$



















                  4
















                  $begingroup$

                  Use TagSetDelayed to define a function that behaves as desired:



                  ClearAll[iDentity]
                  iDentity /: iDentity[___], a : __ := iDentity[a]
                  iDentity /: Tuples[iDentity[a_]] := a

                  Tuples[iDentity[], q]



                  q




                  Tuples[iDentity[blah], 1, 2, 3]



                  1, 2, 3




                  Alternatively, define your function altTuples with two signatures:



                  ClearAll[altTuples]
                  altTuples[tuplesIdentity ] := a
                  altTuples[x_] := Tuples[x]

                  altTuples[x, y, 1, 2]



                  x, 1, x, 2, y, 1, y, 2




                  altTuples[tuplesIdentity, 1, 2]



                  1, 2




                  altTuples[, 1, 2]



                  1, 2







                  share|improve this answer












                  $endgroup$

















                    4














                    4










                    4







                    $begingroup$

                    Use TagSetDelayed to define a function that behaves as desired:



                    ClearAll[iDentity]
                    iDentity /: iDentity[___], a : __ := iDentity[a]
                    iDentity /: Tuples[iDentity[a_]] := a

                    Tuples[iDentity[], q]



                    q




                    Tuples[iDentity[blah], 1, 2, 3]



                    1, 2, 3




                    Alternatively, define your function altTuples with two signatures:



                    ClearAll[altTuples]
                    altTuples[tuplesIdentity ] := a
                    altTuples[x_] := Tuples[x]

                    altTuples[x, y, 1, 2]



                    x, 1, x, 2, y, 1, y, 2




                    altTuples[tuplesIdentity, 1, 2]



                    1, 2




                    altTuples[, 1, 2]



                    1, 2







                    share|improve this answer












                    $endgroup$



                    Use TagSetDelayed to define a function that behaves as desired:



                    ClearAll[iDentity]
                    iDentity /: iDentity[___], a : __ := iDentity[a]
                    iDentity /: Tuples[iDentity[a_]] := a

                    Tuples[iDentity[], q]



                    q




                    Tuples[iDentity[blah], 1, 2, 3]



                    1, 2, 3




                    Alternatively, define your function altTuples with two signatures:



                    ClearAll[altTuples]
                    altTuples[tuplesIdentity ] := a
                    altTuples[x_] := Tuples[x]

                    altTuples[x, y, 1, 2]



                    x, 1, x, 2, y, 1, y, 2




                    altTuples[tuplesIdentity, 1, 2]



                    1, 2




                    altTuples[, 1, 2]



                    1, 2








                    share|improve this answer















                    share|improve this answer




                    share|improve this answer








                    edited Jul 8 at 1:48

























                    answered Jul 7 at 23:21









                    kglrkglr

                    224k10 gold badges254 silver badges511 bronze badges




                    224k10 gold badges254 silver badges511 bronze badges
























                        0
















                        $begingroup$

                        I think this is what you want:



                        altTuples[p_List, q_List] := If[Length[p] == 0, q, Tuples[p, q]]


                        The statement



                        altTuples[, d, e, f]


                        returns



                        d, e, f


                        and



                        altTuples[a, b, c, d, e, f]


                        returns



                        a, d, a, e, a, f, b, d, b, e, b, f, c, d, c, e, c, f





                        share|improve this answer










                        $endgroup$



















                          0
















                          $begingroup$

                          I think this is what you want:



                          altTuples[p_List, q_List] := If[Length[p] == 0, q, Tuples[p, q]]


                          The statement



                          altTuples[, d, e, f]


                          returns



                          d, e, f


                          and



                          altTuples[a, b, c, d, e, f]


                          returns



                          a, d, a, e, a, f, b, d, b, e, b, f, c, d, c, e, c, f





                          share|improve this answer










                          $endgroup$

















                            0














                            0










                            0







                            $begingroup$

                            I think this is what you want:



                            altTuples[p_List, q_List] := If[Length[p] == 0, q, Tuples[p, q]]


                            The statement



                            altTuples[, d, e, f]


                            returns



                            d, e, f


                            and



                            altTuples[a, b, c, d, e, f]


                            returns



                            a, d, a, e, a, f, b, d, b, e, b, f, c, d, c, e, c, f





                            share|improve this answer










                            $endgroup$



                            I think this is what you want:



                            altTuples[p_List, q_List] := If[Length[p] == 0, q, Tuples[p, q]]


                            The statement



                            altTuples[, d, e, f]


                            returns



                            d, e, f


                            and



                            altTuples[a, b, c, d, e, f]


                            returns



                            a, d, a, e, a, f, b, d, b, e, b, f, c, d, c, e, c, f






                            share|improve this answer













                            share|improve this answer




                            share|improve this answer










                            answered Jul 8 at 23:34









                            mjwmjw

                            1,60513 bronze badges




                            1,60513 bronze badges































                                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%2f201715%2fwhat-is-the-identity-for-tuples%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

                                Distance measures on a map of a game The 2019 Stack Overflow Developer Survey Results Are Inmin distance in a graphShortest distance path on contour plotHow to plot a tilted map?Finding points outside of a diskDelaunay link distanceAnnulus from GeoDisks: drawing a ring on a mapNegative Correlation DistanceFind distance along a path (GPS coordinates)Finding position at given distance in a GeoPathMathematics behind distance estimation using camera

                                How to get a smooth, uniform ParametricPlot of a 2D Region?How to plot a complicated Region?How to exclude a region from ParametricPlotHow discretize a region placing vertices on a specific non-uniform gridHow to transform a Plot or a ParametricPlot into a RegionHow can I get a smooth plot of a bounded region?Smooth ParametricPlot3D with RegionFunction?Smooth border of a region ParametricPlotSmooth region boundarySmooth region plot from list of pointsGet minimum y of a certain x in a region

                                Genealogie vun de Merowenger Vum Merowech bis zum Chilperich I. | Navigatiounsmenü