The following example is a simplified version of a problem I am working on:
equivalent[x_, y_] := Mod[x, 7] == Mod[y, 7]
Given a list, say {3, 7, 5} and an integer 21. I need to determine the position of 21 in the list. If I use PositionIndex (which is what I want to use) then the result is
Missing["KeyAbsent", 21]
I need the result to be {2}, i.e. the position of 7 in the list (where 7 is identified with 21 through the equivalence relation).
Is there a way to define PositionIndex up to isomorphism? I.e. so that it returns positions of elements A that are equivalent to list elements B in the list by returning the position of B (for the element A)?
ETA: the result should not depend on the actual value of 7.
So in case the list is {3,14,5} and the element is 21, the result should still be {2}. In the application I cannot assume anything about the integers contained in the list (or the element of which the position in the list needs to be determined). The position should be {2} in case the given element is equivalent to the list element in second position.
equivalent[x_, y_] := Mod[x - y, 7] == 0; equivclass[x_] := Mod[x, 7, 1]; Position[{3, 7, 5}, equivclass[21]]
$\endgroup$Position[equivclass/@{3, 21, 5}, equivclass[21]]
$\endgroup$