Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Help with Mathematica?

  1. Oct 11, 2013 #1
    Part A:
    Get the list of pairs of the form {language,number of words in dictionary}. Call this list Alength.

    What I did:
    lang = DictionaryLookup[All] to get all the languages. Then,
    Alength = {Length[DictionaryLookup[{"Finnish", All}]], Length[DictionaryLookup[{"Arabic", All}]]}.........}

    What is a shorter way of doing this?

    Part B:

    Get a list of the form {language, length longest word in the dictionary}. Call this list longestword.

    I did:
    longestword = Max[DictionaryLookup[All]]

    But that's not coming out correctly.

    Part C:
    Look at all the words contained in all the dictionaries. What are the ones of maximum length?

    I did:

    It comes out as 19, but I think there's something wrong here as well.

    Part D:
    What are all the words of length 20 in the Mathematica English dictionary.
    This one I have no idea.
  2. jcsd
  3. Oct 11, 2013 #2
    Almost every time you "want to do the same thing to every element in a list" the solution is to use the Map function. Look in the help system for Map and see if you can see a way to use that.

    There are two methods of using this, first to define a function like f and then use Map[f, lang], the second is to use a shortcut method of defining functions using # and &. That second method is probably difficult to understand initially, so using the first method might be best to start with.

    Hint: What is DictionaryLookup[All] and what would Max of that be? Why would that not be what you want? It is also possible that you might have mis-quoted that question.

    Again, look at StringLength[lang] and see if that is exactly what Max will accept.

    Study the hints. Try to understand the method they are suggesting for diagnosing when something doesn't work. Then see if you can apply those ideas to make progress on the last problem.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook