Group Abstract Group Abstract

Message Boards Message Boards

1
|
4.1K Views
|
1 Reply
|
4 Total Likes
View groups...
Share
Share this post:
GROUPS:

[?]Create a list that takes the nth element from each sublist of nestedlist

Posted 7 years ago

I have a large list of the following form:

mylist = {{a,b,c},{d,e,f},{g,h,i},{j,k,l}, ... }

I'd like to create a new list that takes the nth element from each sublist, and puts it in a new list. For example, if I want the first element from each sublist in "mylist" list put into a new list, my output would be:

mynewlist = {a,d,g,j, ... }

Can someone give me an idea of how to do this?

Thanks!

POSTED BY: ian gullett
In[1]:= test = Partition[Range[9], 3]

Out[1]= {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}

In[2]:= test[[All, 1]]

Out[2]= {1, 4, 7}

In[3]:= test[[All, 2]]

Out[3]= {2, 5, 8}

In[4]:= test[[All, 3]]

Out[4]= {3, 6, 9}
POSTED BY: Frank Kampas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard