# Is there an easy way to extract data?Inverse function of Thread

I want to learn some tips to deal data.
If i want connect two data with Rule.

a = Array[Sqrt, 10]; b = Array[Sin, 10];

Then i gets.

{1 -> Sin[1], Sqrt[2] -> Sin[2], Sqrt[3] -> Sin[3], 2 -> Sin[4],
Sqrt[5] -> Sin[5], Sqrt[6] -> Sin[6], Sqrt[7] -> Sin[7],
2 Sqrt[2] -> Sin[8], 3 -> Sin[9], Sqrt[10] -> Sin[10]}

I want to extract the result.That means an inverse function of Thread.

I know a solution is a=d[[;;,1]];b=d[[;;,2]].
Is there a better?

• Proposed duplicate: (130093) Apr 11, 2017 at 12:24

You can use Thread a second time:

a = Array[Sqrt, 10]; b = Array[Sin, 10];

{aa, bb} = List @@ Thread[x, Rule];

aa === a
bb === b
True

True

Or a bit more concisely, but perhaps not in the spirit you seek:

{aa, bb} = Thread[List @@@ x];
• I find a strange thing.  resource = ResourceObject["MNIST"]; trainingData = ResourceData[resource, "TrainingData"]; fe[image_] := ImageData[image] // Flatten; {a, b} = Thread[List @@@ trainingData ]; trainingData1 = Thread[(fe/@a) -> b]  It needs lots of memories and will not stop.
– erow
Apr 2, 2017 at 4:53

You'll get lots of variants. I always use Part like in your example. However one way, different to above, admittedly not an "UnThread" is:

{a, b} = Transpose[x /. Rule -> List]