Supposed that:
list = {2, 3, 5, 7, 9};
sublist = {{3, 3, 5}, {2, 2, 2, 7, 9}};
I want to change each sublist in sublist as following:
- Find the positions of elements in sublist in list.So,
{3, 3, 5} -> {2, 2, 3} and {2, 2, 2, 7, 9} -> {1, 1, 1, 4, 5}.
sublist1 = {{2 ,2, 3}, {1, 1, 1, 4, 5}};
2,Change each sublist in sublist1 to sparsearray:
{2, 2, 3} -> {0, 2, 1, 0, 0} and {1, 1, 1, 4, 5} -> {3, 0, 0, 1, 1}.
sublist2 = {{0, 2, 1, 0, 0}, {3, 0, 0, 1, 1}};
How to do it?
list
's? $\endgroup$ – Kuba♦ Sep 15 '13 at 22:40