DeleteCases does not work with EvenQ? While `Select` works fine

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











up vote
1
down vote

favorite












EvenQ[FromDigits /@ Tuples[2, 3, 5, 7, 5]]


Works fine. But



DeleteCases[FromDigits /@ Tuples[2, 3, 5, 7, 5], EvenQ]
DeleteCases[FromDigits /@ Tuples[2, 3, 5, 7, 5], _EvenQ]


does not seem to be deleting any Even numbers as expected?



What am I doing wrong?



In comparison,



Select[FromDigits /@ Tuples[2, 3, 5, 7, 5], OddQ]


Works perfectly fine!!



MMA: 11.3 X64 (Win)










share|improve this question

























    up vote
    1
    down vote

    favorite












    EvenQ[FromDigits /@ Tuples[2, 3, 5, 7, 5]]


    Works fine. But



    DeleteCases[FromDigits /@ Tuples[2, 3, 5, 7, 5], EvenQ]
    DeleteCases[FromDigits /@ Tuples[2, 3, 5, 7, 5], _EvenQ]


    does not seem to be deleting any Even numbers as expected?



    What am I doing wrong?



    In comparison,



    Select[FromDigits /@ Tuples[2, 3, 5, 7, 5], OddQ]


    Works perfectly fine!!



    MMA: 11.3 X64 (Win)










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      EvenQ[FromDigits /@ Tuples[2, 3, 5, 7, 5]]


      Works fine. But



      DeleteCases[FromDigits /@ Tuples[2, 3, 5, 7, 5], EvenQ]
      DeleteCases[FromDigits /@ Tuples[2, 3, 5, 7, 5], _EvenQ]


      does not seem to be deleting any Even numbers as expected?



      What am I doing wrong?



      In comparison,



      Select[FromDigits /@ Tuples[2, 3, 5, 7, 5], OddQ]


      Works perfectly fine!!



      MMA: 11.3 X64 (Win)










      share|improve this question













      EvenQ[FromDigits /@ Tuples[2, 3, 5, 7, 5]]


      Works fine. But



      DeleteCases[FromDigits /@ Tuples[2, 3, 5, 7, 5], EvenQ]
      DeleteCases[FromDigits /@ Tuples[2, 3, 5, 7, 5], _EvenQ]


      does not seem to be deleting any Even numbers as expected?



      What am I doing wrong?



      In comparison,



      Select[FromDigits /@ Tuples[2, 3, 5, 7, 5], OddQ]


      Works perfectly fine!!



      MMA: 11.3 X64 (Win)







      filtering conditional






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 1 hour ago









      Chen Stats Yu

      2,5211335




      2,5211335




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          For the selection criterion, Select uses a (pure) function, while *Cases uses a pattern. Code below works.



          DeleteCases[FromDigits /@ Tuples[2, 3, 5, 7, 5], _?EvenQ]





          share|improve this answer






















          • I cannot believe it's such a simple tweak!! The examples in the documentation is not any more useful than your answer! THANKS!
            – Chen Stats Yu
            58 mins ago






          • 2




            @Chen: the thing to remember is that the second argument of Cases/DeleteCases is always a pattern, while for Select, the second argument is an expression test. So, Cases[(* stuff *), EvenQ] actually means "take everything that matches the symbol EvenQ", while Cases[(* stuff *), _?EvenQ] (and Cases[(* stuff *), n_ /; EvenQ[n]] as well) read as "take everything that gives True when EvenQ is applied", which was what was wanted.
            – J. M. is computer-less♦
            32 mins ago







          • 1




            You can see the difference by evaluating Cases[8, EvenQ, EvenQ], Cases[8, EvenQ, _?EvenQ].
            – J. M. is computer-less♦
            29 mins ago










          • @J.M.iscomputer-less good point
            – Î‘λέξανδρος Ζεγγ
            24 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',
          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%2f184004%2fdeletecases-does-not-work-with-evenq-while-select-works-fine%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          4
          down vote



          accepted










          For the selection criterion, Select uses a (pure) function, while *Cases uses a pattern. Code below works.



          DeleteCases[FromDigits /@ Tuples[2, 3, 5, 7, 5], _?EvenQ]





          share|improve this answer






















          • I cannot believe it's such a simple tweak!! The examples in the documentation is not any more useful than your answer! THANKS!
            – Chen Stats Yu
            58 mins ago






          • 2




            @Chen: the thing to remember is that the second argument of Cases/DeleteCases is always a pattern, while for Select, the second argument is an expression test. So, Cases[(* stuff *), EvenQ] actually means "take everything that matches the symbol EvenQ", while Cases[(* stuff *), _?EvenQ] (and Cases[(* stuff *), n_ /; EvenQ[n]] as well) read as "take everything that gives True when EvenQ is applied", which was what was wanted.
            – J. M. is computer-less♦
            32 mins ago







          • 1




            You can see the difference by evaluating Cases[8, EvenQ, EvenQ], Cases[8, EvenQ, _?EvenQ].
            – J. M. is computer-less♦
            29 mins ago










          • @J.M.iscomputer-less good point
            – Î‘λέξανδρος Ζεγγ
            24 mins ago














          up vote
          4
          down vote



          accepted










          For the selection criterion, Select uses a (pure) function, while *Cases uses a pattern. Code below works.



          DeleteCases[FromDigits /@ Tuples[2, 3, 5, 7, 5], _?EvenQ]





          share|improve this answer






















          • I cannot believe it's such a simple tweak!! The examples in the documentation is not any more useful than your answer! THANKS!
            – Chen Stats Yu
            58 mins ago






          • 2




            @Chen: the thing to remember is that the second argument of Cases/DeleteCases is always a pattern, while for Select, the second argument is an expression test. So, Cases[(* stuff *), EvenQ] actually means "take everything that matches the symbol EvenQ", while Cases[(* stuff *), _?EvenQ] (and Cases[(* stuff *), n_ /; EvenQ[n]] as well) read as "take everything that gives True when EvenQ is applied", which was what was wanted.
            – J. M. is computer-less♦
            32 mins ago







          • 1




            You can see the difference by evaluating Cases[8, EvenQ, EvenQ], Cases[8, EvenQ, _?EvenQ].
            – J. M. is computer-less♦
            29 mins ago










          • @J.M.iscomputer-less good point
            – Î‘λέξανδρος Ζεγγ
            24 mins ago












          up vote
          4
          down vote



          accepted







          up vote
          4
          down vote



          accepted






          For the selection criterion, Select uses a (pure) function, while *Cases uses a pattern. Code below works.



          DeleteCases[FromDigits /@ Tuples[2, 3, 5, 7, 5], _?EvenQ]





          share|improve this answer














          For the selection criterion, Select uses a (pure) function, while *Cases uses a pattern. Code below works.



          DeleteCases[FromDigits /@ Tuples[2, 3, 5, 7, 5], _?EvenQ]






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 57 mins ago

























          answered 58 mins ago









          Αλέξανδρος Ζεγγ

          2,6541826




          2,6541826











          • I cannot believe it's such a simple tweak!! The examples in the documentation is not any more useful than your answer! THANKS!
            – Chen Stats Yu
            58 mins ago






          • 2




            @Chen: the thing to remember is that the second argument of Cases/DeleteCases is always a pattern, while for Select, the second argument is an expression test. So, Cases[(* stuff *), EvenQ] actually means "take everything that matches the symbol EvenQ", while Cases[(* stuff *), _?EvenQ] (and Cases[(* stuff *), n_ /; EvenQ[n]] as well) read as "take everything that gives True when EvenQ is applied", which was what was wanted.
            – J. M. is computer-less♦
            32 mins ago







          • 1




            You can see the difference by evaluating Cases[8, EvenQ, EvenQ], Cases[8, EvenQ, _?EvenQ].
            – J. M. is computer-less♦
            29 mins ago










          • @J.M.iscomputer-less good point
            – Î‘λέξανδρος Ζεγγ
            24 mins ago
















          • I cannot believe it's such a simple tweak!! The examples in the documentation is not any more useful than your answer! THANKS!
            – Chen Stats Yu
            58 mins ago






          • 2




            @Chen: the thing to remember is that the second argument of Cases/DeleteCases is always a pattern, while for Select, the second argument is an expression test. So, Cases[(* stuff *), EvenQ] actually means "take everything that matches the symbol EvenQ", while Cases[(* stuff *), _?EvenQ] (and Cases[(* stuff *), n_ /; EvenQ[n]] as well) read as "take everything that gives True when EvenQ is applied", which was what was wanted.
            – J. M. is computer-less♦
            32 mins ago







          • 1




            You can see the difference by evaluating Cases[8, EvenQ, EvenQ], Cases[8, EvenQ, _?EvenQ].
            – J. M. is computer-less♦
            29 mins ago










          • @J.M.iscomputer-less good point
            – Î‘λέξανδρος Ζεγγ
            24 mins ago















          I cannot believe it's such a simple tweak!! The examples in the documentation is not any more useful than your answer! THANKS!
          – Chen Stats Yu
          58 mins ago




          I cannot believe it's such a simple tweak!! The examples in the documentation is not any more useful than your answer! THANKS!
          – Chen Stats Yu
          58 mins ago




          2




          2




          @Chen: the thing to remember is that the second argument of Cases/DeleteCases is always a pattern, while for Select, the second argument is an expression test. So, Cases[(* stuff *), EvenQ] actually means "take everything that matches the symbol EvenQ", while Cases[(* stuff *), _?EvenQ] (and Cases[(* stuff *), n_ /; EvenQ[n]] as well) read as "take everything that gives True when EvenQ is applied", which was what was wanted.
          – J. M. is computer-less♦
          32 mins ago





          @Chen: the thing to remember is that the second argument of Cases/DeleteCases is always a pattern, while for Select, the second argument is an expression test. So, Cases[(* stuff *), EvenQ] actually means "take everything that matches the symbol EvenQ", while Cases[(* stuff *), _?EvenQ] (and Cases[(* stuff *), n_ /; EvenQ[n]] as well) read as "take everything that gives True when EvenQ is applied", which was what was wanted.
          – J. M. is computer-less♦
          32 mins ago





          1




          1




          You can see the difference by evaluating Cases[8, EvenQ, EvenQ], Cases[8, EvenQ, _?EvenQ].
          – J. M. is computer-less♦
          29 mins ago




          You can see the difference by evaluating Cases[8, EvenQ, EvenQ], Cases[8, EvenQ, _?EvenQ].
          – J. M. is computer-less♦
          29 mins ago












          @J.M.iscomputer-less good point
          – Î‘λέξανδρος Ζεγγ
          24 mins ago




          @J.M.iscomputer-less good point
          – Î‘λέξανδρος Ζεγγ
          24 mins 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%2f184004%2fdeletecases-does-not-work-with-evenq-while-select-works-fine%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