Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have defined three lists and I need to be able to take elements from them periodically and put them in a new list. I know I need to use some form of a loop but I am at a loss. Any suggestions?

share|improve this question
    
Try looking up Table, Part and Span. –  s0rce Mar 30 '13 at 1:34
    
MapThread will also prove useful and no loop should be necessary. –  image_doctor Mar 30 '13 at 1:48
    
What criterion determines whether you take them from the original list. Their position? Their value? You may want to look at Cases and Select. –  David Carraher Mar 30 '13 at 1:54
    
I did it without using a loop by primarily using Table, Partition, and Riffle. I manipulated four lists of matrices into a single superlist containing 6 lists. From here I need to create 6 matrix equations. I went about this by making 2 lists from each sublist and then changed the head but I need to be able to do this iteratively. –  Jarod Benowitz Mar 30 '13 at 2:36
1  
Please provide an example of the three input lists and your desired output. At the moment this question is too vague. –  Simon Woods Mar 30 '13 at 11:16
show 1 more comment

closed as not a real question by Yves Klett, Mr.Wizard Apr 29 '13 at 8:05

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

A little hard to tell what you are looking for, but here's a stab. Say you have three lists:

lis1 = {a1, b1, c1, d1};
lis2 = {a2, b2, c2, d2};
lis3 = {a3, b3, c3, d3};

And what you want to do is to "take elements from them periodically and put them in a new list". If we interpret this to mean you want to end up with the list:

{a1, a2, a3, b1, b2, b3, c1, c2, c3, d1, d2, d3}

then you can do this using

Flatten[Transpose[{lis1, lis2, lis3}]]

If this isn't what you are looking to do, please give a simple example so we can know what you are looking for.

share|improve this answer
    
Alternatively: Flatten[{lis1, lis2, lis3}, {{2, 1}}] –  Simon Woods Apr 29 '13 at 7:45
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.