DeleteCases does not work with EvenQ? While `Select` works fine
Clash 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)
filtering conditional
add a comment |Â
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)
filtering conditional
add a comment |Â
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)
filtering conditional
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
filtering conditional
asked 1 hour ago
Chen Stats Yu
2,5211335
2,5211335
add a comment |Â
add a comment |Â
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]
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 ofCases
/DeleteCases
is always a pattern, while forSelect
, the second argument is an expression test. So,Cases[(* stuff *), EvenQ]
actually means "take everything that matches the symbolEvenQ
", whileCases[(* stuff *), _?EvenQ]
(andCases[(* stuff *), n_ /; EvenQ[n]]
as well) read as "take everything that givesTrue
whenEvenQ
is applied", which was what was wanted.
– J. M. is computer-less♦
32 mins ago
1
You can see the difference by evaluatingCases[8, EvenQ, EvenQ], Cases[8, EvenQ, _?EvenQ]
.
– J. M. is computer-less♦
29 mins ago
@J.M.iscomputer-less good point
– Î‘λÎÂξανδÃÂο Ζεγγ
24 mins ago
add a comment |Â
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]
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 ofCases
/DeleteCases
is always a pattern, while forSelect
, the second argument is an expression test. So,Cases[(* stuff *), EvenQ]
actually means "take everything that matches the symbolEvenQ
", whileCases[(* stuff *), _?EvenQ]
(andCases[(* stuff *), n_ /; EvenQ[n]]
as well) read as "take everything that givesTrue
whenEvenQ
is applied", which was what was wanted.
– J. M. is computer-less♦
32 mins ago
1
You can see the difference by evaluatingCases[8, EvenQ, EvenQ], Cases[8, EvenQ, _?EvenQ]
.
– J. M. is computer-less♦
29 mins ago
@J.M.iscomputer-less good point
– Î‘λÎÂξανδÃÂο Ζεγγ
24 mins ago
add a comment |Â
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]
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 ofCases
/DeleteCases
is always a pattern, while forSelect
, the second argument is an expression test. So,Cases[(* stuff *), EvenQ]
actually means "take everything that matches the symbolEvenQ
", whileCases[(* stuff *), _?EvenQ]
(andCases[(* stuff *), n_ /; EvenQ[n]]
as well) read as "take everything that givesTrue
whenEvenQ
is applied", which was what was wanted.
– J. M. is computer-less♦
32 mins ago
1
You can see the difference by evaluatingCases[8, EvenQ, EvenQ], Cases[8, EvenQ, _?EvenQ]
.
– J. M. is computer-less♦
29 mins ago
@J.M.iscomputer-less good point
– Î‘λÎÂξανδÃÂο Ζεγγ
24 mins ago
add a comment |Â
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]
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]
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 ofCases
/DeleteCases
is always a pattern, while forSelect
, the second argument is an expression test. So,Cases[(* stuff *), EvenQ]
actually means "take everything that matches the symbolEvenQ
", whileCases[(* stuff *), _?EvenQ]
(andCases[(* stuff *), n_ /; EvenQ[n]]
as well) read as "take everything that givesTrue
whenEvenQ
is applied", which was what was wanted.
– J. M. is computer-less♦
32 mins ago
1
You can see the difference by evaluatingCases[8, EvenQ, EvenQ], Cases[8, EvenQ, _?EvenQ]
.
– J. M. is computer-less♦
29 mins ago
@J.M.iscomputer-less good point
– Î‘λÎÂξανδÃÂο Ζεγγ
24 mins ago
add a comment |Â
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 ofCases
/DeleteCases
is always a pattern, while forSelect
, the second argument is an expression test. So,Cases[(* stuff *), EvenQ]
actually means "take everything that matches the symbolEvenQ
", whileCases[(* stuff *), _?EvenQ]
(andCases[(* stuff *), n_ /; EvenQ[n]]
as well) read as "take everything that givesTrue
whenEvenQ
is applied", which was what was wanted.
– J. M. is computer-less♦
32 mins ago
1
You can see the difference by evaluatingCases[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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password