New Reply

If I have a list that contains 16 sublist (enclosed in 2 curly

 
Share Thread Thread Tools
Feb28-11, 07:13 PM   #1
 

If I have a list that contains 16 sublist (enclosed in 2 curly


If I have a list that contains 16 sublist (enclosed in 2 curly bracets),
L1 = {{{1, 1}, {1, 5}, {1, 8}}, {{2, 6}, {1, 10}, {0, 12}},
{{3, 2}, {1, 4}, {0, 15}}, {{1, 8}, {1, 14}, {2, 17}},
{{1, 2}, {2, 8}, {3, 12}}, {{2, 6}, {2, 11}, {2, 18}},
{{3, 6}, {1, 9}, {2,17}}, {{1, 8}, {3, 18}, {2, 19}} ... ...};

could I create a list from L1 that is made up of sublist 1, 2, 3, 4, 9, 10, 11,
12 and another that is made up of sublist 5, 6, 7, 8, 13, 14, 15, 16

I have had the idea of using Mod but don' t quite know how to
constuct it:

sub = 0;
sub++;
If[Mod[sub, 8, 1] < 4, Map[something???, L1], Map[something???,L1]]
PhysOrg.com
PhysOrg
science news on PhysOrg.com

>> Galaxies fed by funnels of fuel
>> The better to see you with: Scientists build record-setting metamaterial flat lens
>> Google eyes emerging markets networks
Feb28-11, 07:56 PM   #2
 
With the nested {} in your L1 it seems that you have a 3 dimensional "matrix." Is that what you really have? Or do you have some extra {} that are not really in your data?

If all those {} are actually present then is sublist 1 = {1, 1} or is it {{1, 1}, {1, 5}, {1, 8}}?

Perhaps showing what L2 and L3 should have as values given your L1 would be the most precise way of describing what you need.

If you can answer those questions then it will be possible to show you ways to do what you want.
Mar1-11, 07:18 AM   #3
 
Mentor
The Part operator [[]] can take a list as an argument. E.g.

L1[[{1, 2, 3, 4, 9, 10, 11, 12}]]
Mar1-11, 07:21 AM   #4
 

If I have a list that contains 16 sublist (enclosed in 2 curly


Sorry, didn't make it very clear

sublist 1 = {{1, 1}, {1, 5}, {1, 8}}
sublist 2 = {{2, 6}, {1, 10}, {0, 12}} ...

so I want a new list that will be {sublist 1,sublist 2,sublist 3,sublist 4,sublist 9,sublist 10, sublist 11,sublist 12}
And another {sublist 5,sublist 6,sublist 7,sublist 8,sublist 13,sublist 14, sublist 15,sublist 16}
Mar1-11, 02:04 PM   #5
 
As long as Length[L1] is a multiple of 8

In[1]:=L1={{{1,1},{1,5},{1,8}},{{2,6},{1,10},{0,12}},{{3,2},{1,4},{0,15}},{{ 1,8},{1,14},{2,17}},
{{1,2},{2,8},{3,12}},{{2,6},{2,11},{2,18}},{{3,6},{1,9},{2,17}},{{1,8}, {3,18},{2,19}}};

In[2]:=L2=L1[[Flatten[Table[8j+i,{j,0,(Length[L1]-8)/8},{i,1,4}]]]]

In[3]:=L3=L1[[Flatten[Table[8j+i+4,{j,0,(Length[L1]-8)/8},{i,1,4}]]]]
New Reply
Thread Tools


Similar Threads for: If I have a list that contains 16 sublist (enclosed in 2 curly
Thread Forum Replies
Mathematica - turning two lists into an array Engineering, Comp Sci, & Technology Homework 2
Mathematica: If statment for lists Math & Science Software 1
lists in mathematica Math & Science Software 4
Simple problem in Mathematica involving lists Math & Science Software 3
Skipping numbers in lists in Mathematica Math & Science Software 2