1
$\begingroup$

I have list {1, 2, 3, <|"a" -> 1|>, 4, 2}, and I would to find positions of all elements that match the case NOT INTEGER, namely Except[_Integer], on {1} level. So, my expression looks:

Position[{1, 2, 3, <|"a" -> 1|>, 4, 2}, Except[_Integer], {1}]

But it returns {{0}, {4}}

I'm surprised with position {0}. What is explanation for this, and how to avoid {0} in result?

$\endgroup$
  • 6
    $\begingroup$ Position matches all parts of an expression, including the head. You can get rid of it by specifying Heads->False. $\endgroup$ – b3m2a1 Nov 19 '17 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.