# Unclear behaviour of Position, lists and functions in general [duplicate]

This question already has an answer here:

apologies for the title, but I have such a confusion about my question that I haven't been able to formalise a clear title.

My question arise from the "discrepancy" between the results of the following code:

Position[{0, 1/2}, x_ /; x != 0]
Position[{0, 1/Sqrt[2]}, x_ /; x != 0]


{{2}}

{{2, 1}, {2, 2}, {2}}

While I can recover the result by slightly modifying the code:

Position[{0, 1/Sqrt[2]}, x_ /; x != 0,1]


{{2}}

it's still not completely clear what's happening, and if it's supposed to be like that.

Let's see the difference between the two cases:

FullForm@{0, 1/2}
FullForm@{0, 1/Sqrt[2]}


List[0,Rational[1,2]]

List[0,Power[2,Rational[-1,2]]]

At a first sight, there isn't anything weird happening, but they behave differently. By looking at the second element of the list, I get this:

(1/2)[[1]]
(1/Sqrt[2])[[1]]
(1/Sqrt[2])[[2]]


"Part specification (1/2)[[1]] is longer than depth of object."

2

-1/2

In principle, if I have a function I can access it's arguments by indexing:

fun[ind1, ind2][[1]]
fun[ind1, ind2][[2]]


ind1

ind2

Why I can't access the elements of the first function (Rational[1,2]) but I can access the elements of the second one (Power[2,Rational[-1,2]])?

I've been trying to look at the attributes of the two functions:

Attributes[Rational]
Attributes[Power]


{Protected}

{Listable, NumericFunction, OneIdentity, Protected}

But I'm not sure that the answer lies in here...

To sum up my questions:

1. Is Position supposed to work as I showed in the first piece of code?
2. Why I can index the arguments of Power, but not of Rational?

## marked as duplicate by Kuba♦Apr 16 at 8:58

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

• AtomQ@Rational[1, 2] – Kuba Apr 16 at 8:56
• @Kuba Thanks! I was surprised I couldn't find any post that discussed this already, but I must have used wrong keywords :) btw, it's still confusing to me why Rational are atomic elements even if they are composed by two integers (and the function takes two arguments)... – Fraccalo Apr 16 at 10:13