# How to associate the elements of a list to numbers?

I am having problems to understand the association function. I have a list of lists containing numbers:

{{{0.494118, 0.678431, 0.882353, 1.}, {0.498039, 0.682353, 0.886275,
1.}, {0.505882, 0.686275, 0.882353, 1.}, {0.509804, 0.690196,
0.886275, 1.}, {0.521569, 0.694118, 0.886275, 1.}, {0.529412,
0.694118, 0.890196, 1.}, {0.533333, 0.698039, 0.886275,
1.}, {0.537255, 0.701961, 0.890196, 1.},...}}


and I would like something like this:

{{{0.494118, 0.678431, 0.882353, 1.}->1, {0.498039, 0.682353, 0.886275,
1.}->2, {0.505882, 0.686275, 0.882353, 1.}->3...}}


then, the final output should be {1,2,3,...}.

Could you please tell me which functions should I consider to get the final output? Many thanks

list = {{0.494118, 0.678431, 0.882353, 1.}, {0.498039, 0.682353,
0.886275, 1.}, {0.505882, 0.686275, 0.882353, 1.}, {0.509804,
0.690196, 0.886275, 1.}, {0.521569, 0.694118, 0.886275,
1.}, {0.529412, 0.694118, 0.890196, 1.}, {0.533333, 0.698039,
0.886275, 1.}, {0.537255, 0.701961, 0.890196, 1.}};



{{0.494118, 0.678431, 0.882353, 1.} -> 1, {0.498039, 0.682353, 0.886275, 1.} -> 2, {0.505882, 0.686275, 0.882353, 1.} -> 3, {0.509804, 0.690196, 0.886275, 1.} -> 4, {0.521569, 0.694118, 0.886275, 1.} -> 5, {0.529412, 0.694118, 0.890196, 1.} -> 6, {0.533333, 0.698039, 0.886275, 1.} -> 7, {0.537255, 0.701961, 0.890196, 1.} -> 8}

• Many thanks, OkkesDulgerci! – Val Sep 22 at 22:57

You can also use MapIndexed:

MapIndexed[# -> #2[[1]] &, list]


{{0.494118, 0.678431, 0.882353, 1.} -> 1,
{0.498039, 0.682353, 0.886275, 1.} -> 2,
{0.505882, 0.686275, 0.882353, 1.} -> 3,
{0.509804, 0.690196, 0.886275, 1.} -> 4,
{0.521569, 0.694118, 0.886275, 1.} -> 5,
{0.529412, 0.694118, 0.890196, 1.} -> 6,
{0.533333, 0.698039, 0.886275, 1.} -> 7,
{0.537255, 0.701961, 0.890196, 1.} -> 8}