Finding the longest word in a list (WordList[])

Hi guys I am having problems with finding the longest word available in WordList["English"] I have found that the longest word has 24 characters thanks to this line

Max[StringLength[WordList[]]]


but I don't know how to find the position of the word Knowing her length. I thought I need some selection rule but I fail to implement it. any help?

• So you want to know the longest word, its position in the list or both?
– Kuba
Aug 14, 2016 at 10:45
• Answer to the title: MaximalBy[StringLength]@WordList[].
– Kuba
Aug 14, 2016 at 10:46
• the word, however i think i need the position to use Take[WordList[],n]... Aug 14, 2016 at 10:46
• You need the position for Take but don't assume you need Take.
– Kuba
Aug 14, 2016 at 10:47
• Now that you know that the longest entry in WordList[] is 24 characters long, why not Select[] all the entries in it whose StringLength[] is == 24? (This is one of the things I like about this language; sometimes the solution statement directly translates to usable code.) Aug 14, 2016 at 10:48

ok one solution I found, aside the one given by Kuba , is

length = Max[StringLength[WordList[]]]
Select[WordList[], StringLength[#] == length & ]


a second solution with the function Pick[] is

Pick[WordList[], StringLength[WordList[]], length]


A third one with Cases[]

f = StringLength[#] == 24 &;
Cases[WordList[], x_ /; f[x]]


a BarChart with the absolutetiming:

• Well done. If you need further exercise, think about how to implement this with Pick[] or Cases[]. Aug 14, 2016 at 11:13
• @J.M. i will thanks Aug 14, 2016 at 11:18
• @J.M. i found the two additional solutions but i did not understand the difference between the patterns used with Cases and the function with select[].what's the difference?they do exactly the same thing... Aug 14, 2016 at 12:44