Removing lists with zero at any position

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
8
down vote

favorite
1












I want to delete the complete list within a list containing 0 at any position.



I tried using:



DeleteCases[Tuples[Range[-2, 2], 2], 0 ..]



-2, -2, -2, -1, -2, 0, -2, 1, -2, 2, -1, -2, -1, -1, -1, 0,
-1, 1, -1, 2, 0, -2, 0, -1, 0, 1, 0, 2, 1, -2, 1, -1, 1, 0, 1, 1,
1, 2, 2, -2, 2, -1, 2, 0, 2, 1, 2, 2




But only the lists starting with 0 are removed.



How can I remove the entire list that contains 0 at any place?










share|improve this question



























    up vote
    8
    down vote

    favorite
    1












    I want to delete the complete list within a list containing 0 at any position.



    I tried using:



    DeleteCases[Tuples[Range[-2, 2], 2], 0 ..]



    -2, -2, -2, -1, -2, 0, -2, 1, -2, 2, -1, -2, -1, -1, -1, 0,
    -1, 1, -1, 2, 0, -2, 0, -1, 0, 1, 0, 2, 1, -2, 1, -1, 1, 0, 1, 1,
    1, 2, 2, -2, 2, -1, 2, 0, 2, 1, 2, 2




    But only the lists starting with 0 are removed.



    How can I remove the entire list that contains 0 at any place?










    share|improve this question

























      up vote
      8
      down vote

      favorite
      1









      up vote
      8
      down vote

      favorite
      1






      1





      I want to delete the complete list within a list containing 0 at any position.



      I tried using:



      DeleteCases[Tuples[Range[-2, 2], 2], 0 ..]



      -2, -2, -2, -1, -2, 0, -2, 1, -2, 2, -1, -2, -1, -1, -1, 0,
      -1, 1, -1, 2, 0, -2, 0, -1, 0, 1, 0, 2, 1, -2, 1, -1, 1, 0, 1, 1,
      1, 2, 2, -2, 2, -1, 2, 0, 2, 1, 2, 2




      But only the lists starting with 0 are removed.



      How can I remove the entire list that contains 0 at any place?










      share|improve this question















      I want to delete the complete list within a list containing 0 at any position.



      I tried using:



      DeleteCases[Tuples[Range[-2, 2], 2], 0 ..]



      -2, -2, -2, -1, -2, 0, -2, 1, -2, 2, -1, -2, -1, -1, -1, 0,
      -1, 1, -1, 2, 0, -2, 0, -1, 0, 1, 0, 2, 1, -2, 1, -1, 1, 0, 1, 1,
      1, 2, 2, -2, 2, -1, 2, 0, 2, 1, 2, 2




      But only the lists starting with 0 are removed.



      How can I remove the entire list that contains 0 at any place?







      list-manipulation array






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 15 hours ago









      kglr

      159k8184384




      159k8184384










      asked 19 hours ago









      dykes

      836




      836




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          8
          down vote













           DeleteCases[Tuples[Range[-2, 2], 2], ___, 0, ___] (* or *)
          DeleteCases[data, 0, 0|1,0|0,1]



          -2, -2, -2, -1, -2, 1, -2, 2, -1, -2, -1, -1, -1,
          1, -1, 2, 1, -2, 1, -1, 1, 1, 1, 2, 2, -2, 2, -1, 2,
          1, 2, 2




          Alternatively, if you can, remove zeros from the input lists before using Tuples:



          Tuples[Join[-Reverse@#, #]&@Range[2],2]



          same result




          Even if data = Tuples[Range[-2, 2], 2] is already created, processing data to create a zero-free input list and using Tuples on it is (to my surprise) faster than using Pick to remove entries with zeros from pairs of data:



          data = Tuples[Range[-100, 100], 2];

          ra = Tuples[Join[-Reverse @ #, #]& @ Range[100],2]; // RepeatedTiming // First



          0.0000524




          rb = With[r = DeleteCases[DeleteDuplicates @ Flatten[data], 0],
          Tuples[r, 2]];// RepeatedTiming // First



          0.000178




          rc = Pick[data, Unitize[data].1, 1, 2];//RepeatedTiming//First (*from @Henrik's answer*)



          0.0013




          rd = DeleteCases[data, 0, 0|1,0|0,1];// RepeatedTiming // First 



          0.017




          re = DeleteCases[data, ___, 0, ___];// RepeatedTiming // First 



          0.026




          rf = Select[data, FreeQ[0] ];// RepeatedTiming // First (*from David's answer *)



          0.060




          ra == rb == rc == rd == re == rf



          True







          share|improve this answer






















          • Well.... if you're free to delete 0 before using Tuples simply use Tuples[-2, -1, 1, 2, 2].
            – David G. Stork
            18 hours ago











          • @David, yes; i used the more cumbersome way to deal with cases like Range[-100, 100]
            – kglr
            18 hours ago






          • 1




            Oh, method b and c... nice out-of-the-box-thinking!
            – Henrik Schumacher
            16 hours ago










          • DeleteCases[DeleteDuplicates @ Flatten[data], 0] is not packed, while Join[-Reverse @ #, #]& @ Range[100] is, explaining the difference in timing
            – Carl Woll
            15 hours ago










          • @CarlWoll, good point. But in this case, DeleteDuplicates @ Flatten[data] (which is packed) already takes 0.00011 seconds (RepeatedTiming) compared to 3.06*10^-6 for Join[-Reverse @ #, #]& @ Range[100], simply because the former processes a list with dimensions 40401,2 and the latter with just 200.
            – kglr
            14 hours ago


















          up vote
          7
          down vote













          Here a more cumbersome (not a code golfer) but faster approach:



          data = Tuples[Range[-100, 100], 2];
          a = DeleteCases[data, ___, 0, ___]; // RepeatedTiming // First
          b = Pick[data, Unitize[data].1, 1, 2]; // RepeatedTiming // First
          a == b



          0.028



          0.00098



          True




          This skips pattern matching in favor of faster vectorized functions.






          share|improve this answer





























            up vote
            7
            down vote













            Or...



            Select[Tuples[Range[-2, 2], 2], ! MemberQ[#, 0] &]


            or as @ThatGravityGuy points out...



            Select[Tuples[Range[-2, 2], 2], FreeQ[#, 0] &]





            share|improve this answer


















            • 1




              Instead of !MemberQ couldn't you just use FreeQ?
              – That Gravity Guy
              18 hours ago










            • Oooh... of course. Yes. Thanks.
              – David G. Stork
              18 hours ago










            • You can use the operator form FreeQ[0] instead of FreeQ[#, 0] &
              – kglr
              17 hours ago











            • .. or operator forms of both Select and FreeQ: Select[FreeQ@0]@data
              – kglr
              15 hours 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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            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%2f181781%2fremoving-lists-with-zero-at-any-position%23new-answer', 'question_page');

            );

            Post as a guest






























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            8
            down vote













             DeleteCases[Tuples[Range[-2, 2], 2], ___, 0, ___] (* or *)
            DeleteCases[data, 0, 0|1,0|0,1]



            -2, -2, -2, -1, -2, 1, -2, 2, -1, -2, -1, -1, -1,
            1, -1, 2, 1, -2, 1, -1, 1, 1, 1, 2, 2, -2, 2, -1, 2,
            1, 2, 2




            Alternatively, if you can, remove zeros from the input lists before using Tuples:



            Tuples[Join[-Reverse@#, #]&@Range[2],2]



            same result




            Even if data = Tuples[Range[-2, 2], 2] is already created, processing data to create a zero-free input list and using Tuples on it is (to my surprise) faster than using Pick to remove entries with zeros from pairs of data:



            data = Tuples[Range[-100, 100], 2];

            ra = Tuples[Join[-Reverse @ #, #]& @ Range[100],2]; // RepeatedTiming // First



            0.0000524




            rb = With[r = DeleteCases[DeleteDuplicates @ Flatten[data], 0],
            Tuples[r, 2]];// RepeatedTiming // First



            0.000178




            rc = Pick[data, Unitize[data].1, 1, 2];//RepeatedTiming//First (*from @Henrik's answer*)



            0.0013




            rd = DeleteCases[data, 0, 0|1,0|0,1];// RepeatedTiming // First 



            0.017




            re = DeleteCases[data, ___, 0, ___];// RepeatedTiming // First 



            0.026




            rf = Select[data, FreeQ[0] ];// RepeatedTiming // First (*from David's answer *)



            0.060




            ra == rb == rc == rd == re == rf



            True







            share|improve this answer






















            • Well.... if you're free to delete 0 before using Tuples simply use Tuples[-2, -1, 1, 2, 2].
              – David G. Stork
              18 hours ago











            • @David, yes; i used the more cumbersome way to deal with cases like Range[-100, 100]
              – kglr
              18 hours ago






            • 1




              Oh, method b and c... nice out-of-the-box-thinking!
              – Henrik Schumacher
              16 hours ago










            • DeleteCases[DeleteDuplicates @ Flatten[data], 0] is not packed, while Join[-Reverse @ #, #]& @ Range[100] is, explaining the difference in timing
              – Carl Woll
              15 hours ago










            • @CarlWoll, good point. But in this case, DeleteDuplicates @ Flatten[data] (which is packed) already takes 0.00011 seconds (RepeatedTiming) compared to 3.06*10^-6 for Join[-Reverse @ #, #]& @ Range[100], simply because the former processes a list with dimensions 40401,2 and the latter with just 200.
              – kglr
              14 hours ago















            up vote
            8
            down vote













             DeleteCases[Tuples[Range[-2, 2], 2], ___, 0, ___] (* or *)
            DeleteCases[data, 0, 0|1,0|0,1]



            -2, -2, -2, -1, -2, 1, -2, 2, -1, -2, -1, -1, -1,
            1, -1, 2, 1, -2, 1, -1, 1, 1, 1, 2, 2, -2, 2, -1, 2,
            1, 2, 2




            Alternatively, if you can, remove zeros from the input lists before using Tuples:



            Tuples[Join[-Reverse@#, #]&@Range[2],2]



            same result




            Even if data = Tuples[Range[-2, 2], 2] is already created, processing data to create a zero-free input list and using Tuples on it is (to my surprise) faster than using Pick to remove entries with zeros from pairs of data:



            data = Tuples[Range[-100, 100], 2];

            ra = Tuples[Join[-Reverse @ #, #]& @ Range[100],2]; // RepeatedTiming // First



            0.0000524




            rb = With[r = DeleteCases[DeleteDuplicates @ Flatten[data], 0],
            Tuples[r, 2]];// RepeatedTiming // First



            0.000178




            rc = Pick[data, Unitize[data].1, 1, 2];//RepeatedTiming//First (*from @Henrik's answer*)



            0.0013




            rd = DeleteCases[data, 0, 0|1,0|0,1];// RepeatedTiming // First 



            0.017




            re = DeleteCases[data, ___, 0, ___];// RepeatedTiming // First 



            0.026




            rf = Select[data, FreeQ[0] ];// RepeatedTiming // First (*from David's answer *)



            0.060




            ra == rb == rc == rd == re == rf



            True







            share|improve this answer






















            • Well.... if you're free to delete 0 before using Tuples simply use Tuples[-2, -1, 1, 2, 2].
              – David G. Stork
              18 hours ago











            • @David, yes; i used the more cumbersome way to deal with cases like Range[-100, 100]
              – kglr
              18 hours ago






            • 1




              Oh, method b and c... nice out-of-the-box-thinking!
              – Henrik Schumacher
              16 hours ago










            • DeleteCases[DeleteDuplicates @ Flatten[data], 0] is not packed, while Join[-Reverse @ #, #]& @ Range[100] is, explaining the difference in timing
              – Carl Woll
              15 hours ago










            • @CarlWoll, good point. But in this case, DeleteDuplicates @ Flatten[data] (which is packed) already takes 0.00011 seconds (RepeatedTiming) compared to 3.06*10^-6 for Join[-Reverse @ #, #]& @ Range[100], simply because the former processes a list with dimensions 40401,2 and the latter with just 200.
              – kglr
              14 hours ago













            up vote
            8
            down vote










            up vote
            8
            down vote









             DeleteCases[Tuples[Range[-2, 2], 2], ___, 0, ___] (* or *)
            DeleteCases[data, 0, 0|1,0|0,1]



            -2, -2, -2, -1, -2, 1, -2, 2, -1, -2, -1, -1, -1,
            1, -1, 2, 1, -2, 1, -1, 1, 1, 1, 2, 2, -2, 2, -1, 2,
            1, 2, 2




            Alternatively, if you can, remove zeros from the input lists before using Tuples:



            Tuples[Join[-Reverse@#, #]&@Range[2],2]



            same result




            Even if data = Tuples[Range[-2, 2], 2] is already created, processing data to create a zero-free input list and using Tuples on it is (to my surprise) faster than using Pick to remove entries with zeros from pairs of data:



            data = Tuples[Range[-100, 100], 2];

            ra = Tuples[Join[-Reverse @ #, #]& @ Range[100],2]; // RepeatedTiming // First



            0.0000524




            rb = With[r = DeleteCases[DeleteDuplicates @ Flatten[data], 0],
            Tuples[r, 2]];// RepeatedTiming // First



            0.000178




            rc = Pick[data, Unitize[data].1, 1, 2];//RepeatedTiming//First (*from @Henrik's answer*)



            0.0013




            rd = DeleteCases[data, 0, 0|1,0|0,1];// RepeatedTiming // First 



            0.017




            re = DeleteCases[data, ___, 0, ___];// RepeatedTiming // First 



            0.026




            rf = Select[data, FreeQ[0] ];// RepeatedTiming // First (*from David's answer *)



            0.060




            ra == rb == rc == rd == re == rf



            True







            share|improve this answer














             DeleteCases[Tuples[Range[-2, 2], 2], ___, 0, ___] (* or *)
            DeleteCases[data, 0, 0|1,0|0,1]



            -2, -2, -2, -1, -2, 1, -2, 2, -1, -2, -1, -1, -1,
            1, -1, 2, 1, -2, 1, -1, 1, 1, 1, 2, 2, -2, 2, -1, 2,
            1, 2, 2




            Alternatively, if you can, remove zeros from the input lists before using Tuples:



            Tuples[Join[-Reverse@#, #]&@Range[2],2]



            same result




            Even if data = Tuples[Range[-2, 2], 2] is already created, processing data to create a zero-free input list and using Tuples on it is (to my surprise) faster than using Pick to remove entries with zeros from pairs of data:



            data = Tuples[Range[-100, 100], 2];

            ra = Tuples[Join[-Reverse @ #, #]& @ Range[100],2]; // RepeatedTiming // First



            0.0000524




            rb = With[r = DeleteCases[DeleteDuplicates @ Flatten[data], 0],
            Tuples[r, 2]];// RepeatedTiming // First



            0.000178




            rc = Pick[data, Unitize[data].1, 1, 2];//RepeatedTiming//First (*from @Henrik's answer*)



            0.0013




            rd = DeleteCases[data, 0, 0|1,0|0,1];// RepeatedTiming // First 



            0.017




            re = DeleteCases[data, ___, 0, ___];// RepeatedTiming // First 



            0.026




            rf = Select[data, FreeQ[0] ];// RepeatedTiming // First (*from David's answer *)



            0.060




            ra == rb == rc == rd == re == rf



            True








            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 9 hours ago

























            answered 19 hours ago









            kglr

            159k8184384




            159k8184384











            • Well.... if you're free to delete 0 before using Tuples simply use Tuples[-2, -1, 1, 2, 2].
              – David G. Stork
              18 hours ago











            • @David, yes; i used the more cumbersome way to deal with cases like Range[-100, 100]
              – kglr
              18 hours ago






            • 1




              Oh, method b and c... nice out-of-the-box-thinking!
              – Henrik Schumacher
              16 hours ago










            • DeleteCases[DeleteDuplicates @ Flatten[data], 0] is not packed, while Join[-Reverse @ #, #]& @ Range[100] is, explaining the difference in timing
              – Carl Woll
              15 hours ago










            • @CarlWoll, good point. But in this case, DeleteDuplicates @ Flatten[data] (which is packed) already takes 0.00011 seconds (RepeatedTiming) compared to 3.06*10^-6 for Join[-Reverse @ #, #]& @ Range[100], simply because the former processes a list with dimensions 40401,2 and the latter with just 200.
              – kglr
              14 hours ago

















            • Well.... if you're free to delete 0 before using Tuples simply use Tuples[-2, -1, 1, 2, 2].
              – David G. Stork
              18 hours ago











            • @David, yes; i used the more cumbersome way to deal with cases like Range[-100, 100]
              – kglr
              18 hours ago






            • 1




              Oh, method b and c... nice out-of-the-box-thinking!
              – Henrik Schumacher
              16 hours ago










            • DeleteCases[DeleteDuplicates @ Flatten[data], 0] is not packed, while Join[-Reverse @ #, #]& @ Range[100] is, explaining the difference in timing
              – Carl Woll
              15 hours ago










            • @CarlWoll, good point. But in this case, DeleteDuplicates @ Flatten[data] (which is packed) already takes 0.00011 seconds (RepeatedTiming) compared to 3.06*10^-6 for Join[-Reverse @ #, #]& @ Range[100], simply because the former processes a list with dimensions 40401,2 and the latter with just 200.
              – kglr
              14 hours ago
















            Well.... if you're free to delete 0 before using Tuples simply use Tuples[-2, -1, 1, 2, 2].
            – David G. Stork
            18 hours ago





            Well.... if you're free to delete 0 before using Tuples simply use Tuples[-2, -1, 1, 2, 2].
            – David G. Stork
            18 hours ago













            @David, yes; i used the more cumbersome way to deal with cases like Range[-100, 100]
            – kglr
            18 hours ago




            @David, yes; i used the more cumbersome way to deal with cases like Range[-100, 100]
            – kglr
            18 hours ago




            1




            1




            Oh, method b and c... nice out-of-the-box-thinking!
            – Henrik Schumacher
            16 hours ago




            Oh, method b and c... nice out-of-the-box-thinking!
            – Henrik Schumacher
            16 hours ago












            DeleteCases[DeleteDuplicates @ Flatten[data], 0] is not packed, while Join[-Reverse @ #, #]& @ Range[100] is, explaining the difference in timing
            – Carl Woll
            15 hours ago




            DeleteCases[DeleteDuplicates @ Flatten[data], 0] is not packed, while Join[-Reverse @ #, #]& @ Range[100] is, explaining the difference in timing
            – Carl Woll
            15 hours ago












            @CarlWoll, good point. But in this case, DeleteDuplicates @ Flatten[data] (which is packed) already takes 0.00011 seconds (RepeatedTiming) compared to 3.06*10^-6 for Join[-Reverse @ #, #]& @ Range[100], simply because the former processes a list with dimensions 40401,2 and the latter with just 200.
            – kglr
            14 hours ago





            @CarlWoll, good point. But in this case, DeleteDuplicates @ Flatten[data] (which is packed) already takes 0.00011 seconds (RepeatedTiming) compared to 3.06*10^-6 for Join[-Reverse @ #, #]& @ Range[100], simply because the former processes a list with dimensions 40401,2 and the latter with just 200.
            – kglr
            14 hours ago











            up vote
            7
            down vote













            Here a more cumbersome (not a code golfer) but faster approach:



            data = Tuples[Range[-100, 100], 2];
            a = DeleteCases[data, ___, 0, ___]; // RepeatedTiming // First
            b = Pick[data, Unitize[data].1, 1, 2]; // RepeatedTiming // First
            a == b



            0.028



            0.00098



            True




            This skips pattern matching in favor of faster vectorized functions.






            share|improve this answer


























              up vote
              7
              down vote













              Here a more cumbersome (not a code golfer) but faster approach:



              data = Tuples[Range[-100, 100], 2];
              a = DeleteCases[data, ___, 0, ___]; // RepeatedTiming // First
              b = Pick[data, Unitize[data].1, 1, 2]; // RepeatedTiming // First
              a == b



              0.028



              0.00098



              True




              This skips pattern matching in favor of faster vectorized functions.






              share|improve this answer
























                up vote
                7
                down vote










                up vote
                7
                down vote









                Here a more cumbersome (not a code golfer) but faster approach:



                data = Tuples[Range[-100, 100], 2];
                a = DeleteCases[data, ___, 0, ___]; // RepeatedTiming // First
                b = Pick[data, Unitize[data].1, 1, 2]; // RepeatedTiming // First
                a == b



                0.028



                0.00098



                True




                This skips pattern matching in favor of faster vectorized functions.






                share|improve this answer














                Here a more cumbersome (not a code golfer) but faster approach:



                data = Tuples[Range[-100, 100], 2];
                a = DeleteCases[data, ___, 0, ___]; // RepeatedTiming // First
                b = Pick[data, Unitize[data].1, 1, 2]; // RepeatedTiming // First
                a == b



                0.028



                0.00098



                True




                This skips pattern matching in favor of faster vectorized functions.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 19 hours ago

























                answered 19 hours ago









                Henrik Schumacher

                37.6k249107




                37.6k249107




















                    up vote
                    7
                    down vote













                    Or...



                    Select[Tuples[Range[-2, 2], 2], ! MemberQ[#, 0] &]


                    or as @ThatGravityGuy points out...



                    Select[Tuples[Range[-2, 2], 2], FreeQ[#, 0] &]





                    share|improve this answer


















                    • 1




                      Instead of !MemberQ couldn't you just use FreeQ?
                      – That Gravity Guy
                      18 hours ago










                    • Oooh... of course. Yes. Thanks.
                      – David G. Stork
                      18 hours ago










                    • You can use the operator form FreeQ[0] instead of FreeQ[#, 0] &
                      – kglr
                      17 hours ago











                    • .. or operator forms of both Select and FreeQ: Select[FreeQ@0]@data
                      – kglr
                      15 hours ago














                    up vote
                    7
                    down vote













                    Or...



                    Select[Tuples[Range[-2, 2], 2], ! MemberQ[#, 0] &]


                    or as @ThatGravityGuy points out...



                    Select[Tuples[Range[-2, 2], 2], FreeQ[#, 0] &]





                    share|improve this answer


















                    • 1




                      Instead of !MemberQ couldn't you just use FreeQ?
                      – That Gravity Guy
                      18 hours ago










                    • Oooh... of course. Yes. Thanks.
                      – David G. Stork
                      18 hours ago










                    • You can use the operator form FreeQ[0] instead of FreeQ[#, 0] &
                      – kglr
                      17 hours ago











                    • .. or operator forms of both Select and FreeQ: Select[FreeQ@0]@data
                      – kglr
                      15 hours ago












                    up vote
                    7
                    down vote










                    up vote
                    7
                    down vote









                    Or...



                    Select[Tuples[Range[-2, 2], 2], ! MemberQ[#, 0] &]


                    or as @ThatGravityGuy points out...



                    Select[Tuples[Range[-2, 2], 2], FreeQ[#, 0] &]





                    share|improve this answer














                    Or...



                    Select[Tuples[Range[-2, 2], 2], ! MemberQ[#, 0] &]


                    or as @ThatGravityGuy points out...



                    Select[Tuples[Range[-2, 2], 2], FreeQ[#, 0] &]






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 18 hours ago

























                    answered 19 hours ago









                    David G. Stork

                    21.4k11646




                    21.4k11646







                    • 1




                      Instead of !MemberQ couldn't you just use FreeQ?
                      – That Gravity Guy
                      18 hours ago










                    • Oooh... of course. Yes. Thanks.
                      – David G. Stork
                      18 hours ago










                    • You can use the operator form FreeQ[0] instead of FreeQ[#, 0] &
                      – kglr
                      17 hours ago











                    • .. or operator forms of both Select and FreeQ: Select[FreeQ@0]@data
                      – kglr
                      15 hours ago












                    • 1




                      Instead of !MemberQ couldn't you just use FreeQ?
                      – That Gravity Guy
                      18 hours ago










                    • Oooh... of course. Yes. Thanks.
                      – David G. Stork
                      18 hours ago










                    • You can use the operator form FreeQ[0] instead of FreeQ[#, 0] &
                      – kglr
                      17 hours ago











                    • .. or operator forms of both Select and FreeQ: Select[FreeQ@0]@data
                      – kglr
                      15 hours ago







                    1




                    1




                    Instead of !MemberQ couldn't you just use FreeQ?
                    – That Gravity Guy
                    18 hours ago




                    Instead of !MemberQ couldn't you just use FreeQ?
                    – That Gravity Guy
                    18 hours ago












                    Oooh... of course. Yes. Thanks.
                    – David G. Stork
                    18 hours ago




                    Oooh... of course. Yes. Thanks.
                    – David G. Stork
                    18 hours ago












                    You can use the operator form FreeQ[0] instead of FreeQ[#, 0] &
                    – kglr
                    17 hours ago





                    You can use the operator form FreeQ[0] instead of FreeQ[#, 0] &
                    – kglr
                    17 hours ago













                    .. or operator forms of both Select and FreeQ: Select[FreeQ@0]@data
                    – kglr
                    15 hours ago




                    .. or operator forms of both Select and FreeQ: Select[FreeQ@0]@data
                    – kglr
                    15 hours ago

















                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f181781%2fremoving-lists-with-zero-at-any-position%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    Confectionery