Wolfram Archive
Wolfram Programming Lab is a legacy product.
All the same functionality and features, including access to Programming Lab Explorations, are available with Wolfram|One.
Start programming now. »
Try it now »
(no sign-in required)

Dictionary First Letters

Find how many words in a dictionary start with each possible first letter.

Run the code to get the list of words in the English dictionary. Try other languages, like "Spanish" or "Russian":

DictionaryLookup[{"English", All}]

Find the first letter of every dictionary word. Try other languages, like "German" or "Hindi":


This gives the first letter of a text string:

StringTake["fish", 1]

This gives the first letter of each word in a list:

StringTake[{"fish", "cow", "ant"}, 1]

This gives the first letter of every word in the dictionary:

StringTake[DictionaryLookup[{"English", All}], 1]

StringTake[DictionaryLookup[{"English", All}], 1]

Make all the letters uppercase. Try making the letters lowercase:


Were going to want to treat uppercase and lowercase letters the same when we count how many words there are that begin with each letter.

The easiest way to do that is to convert all the letters to uppercase:

ToUpperCase[StringTake[DictionaryLookup[{"English", All}], 1]]

You can also convert to lowercase:


ToUpperCase[StringTake[DictionaryLookup[{"English", All}], 1]]

Tally the number of occurrences of each letter. Try other languages, like "French" or "Finnish":


Tally gives the number of times each element occurs in a list.

This list contains two as and three zs:

Tally[{"a", "z", "a", "z", "z"}]

Use Tally to count the number of dictionary words that start with each letter:

Tally[ToUpperCase[StringTake[DictionaryLookup[{"English", All}], 1]]]

Tally[ToUpperCase[StringTake[DictionaryLookup[{"English", All}], 1]]]

Display the letters with their size proportional to their count. Compare English with other languages:

Note: adjust the scale factor by 100 if letters are too small or too big.


This makes a 100-point letter A (a point is a printers measure equal to 1/72 inch):

Style["A", 100]

This does the same thing using a pure function, which is indicated by # and &. A pure function is like a regular function, but it doesnt have a name. The Acalled the argumentis substituted for the # in the expression to the left of &:

Style[#, 100] &["A"]

You can give a pure function two arguments, like the letter and a size. The second argument is indicated in the pure function by #2:

Style[#, #2] &["A", 100]

Pure functions are often used to do something to every element of a list.

This makes every letter in the list the specified size:

Style[#, #2] & @@@ {{"A", 50}, {"B", 100}, {"C", 150}}

Use Row to get a row of letters without braces and commas:

Row[Style[#, #2] & @@@ {{"A", 50}, {"B", 100}, {"C", 150}}]

Do the same thing with the dictionary letter counts. First give the counts the name lettercounts:

lettercounts = Tally[ToUpperCase[StringTake[DictionaryLookup[{"English", All}], 1]]]

Then size the letters using their counts. You need to divide the counts by 100 to get reasonable sizes:

Row[Style[#, #2/100] & @@@ lettercounts]

lettercounts = Tally[ToUpperCase[ StringTake[DictionaryLookup[{"English", All}], 1]]]; Row[Style[#, #2/100] & @@@ lettercounts]