Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say, I have a list


I have a nested list and I want to find the list that has the most words in it and then I want to find the length of those words. How would I do that?

I thought it was




but StringLength doesn't do me any good here since the length of each letter is the same.

share|improve this question
up vote 4 down vote accepted

Since you want to find the sublist with the maximum length (i.e. most number of words), you don't need to concern yourself with StringLength. A simple solution would be to use Pick to select the longest list and then use StringLength to get the lengths.

With[{L = Length /@ stuff}, StringLength@Pick[stuff, L, Max@L]]
(* {{3, 3, 3, 3, 3}} *)
share|improve this answer
Would I also be able to use Select in this case? – thaibak527 Oct 25 '13 at 21:05
Yes, you can use Select. Is there a reason you don't want to use Pick? – R. M. Oct 25 '13 at 21:05
Because I have only used Pick for a simple set of lists, and not really familiar with it. So, if you use Pick here, the program compares the lists, and "picks" the list with the highest amount of strings? – thaibak527 Oct 25 '13 at 21:10
@thaibak527 Yes, it picks the sublists with the maximum length (because I told it to). – R. M. Oct 25 '13 at 21:26
Great great, thank you I will remember that for future – thaibak527 Oct 25 '13 at 22:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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