Let me answer your question by first clarifying some of the fundamentals about Mathematica:
A. Mapping over list. If you have a function, you can apply it to a list of values by using Map
:
Range[10]
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Map[Sqrt, Range[10]]
$\left\{1,\sqrt{2},\sqrt{3},2,\sqrt{5},\sqrt{6},\sqrt{7},2 \sqrt{2},3,\sqrt{10}\right\}$
You can do it with your own functions as well:
f[n_] := n^2 + 1 (* this function squares it's argument and adds 1 *);
Map[f, Range[10]]
{2, 5, 10, 17, 26, 37, 50, 65, 82, 101}
B. Return values. You own functions can return any kind of value, including a list:
f[n_] := {n, n^2, N[Sqrt[n]]} (* returns a list of three elements: a number,
it's square and it's square root *)
Map[f, Range[10]]
Here, you get a list of lists as a result:
{{1, 1, 1.}, {2, 4, 1.41421}, {3, 9, 1.73205}, {4, 16, 2.}, {5, 25,
2.23607}, {6, 36, 2.44949}, {7, 49, 2.64575}, {8, 64, 2.82843}, {9,
81, 3.}, {10, 100, 3.16228}}
C. Solving (a). For your first question, you seem to know already how to return a list of all languages known to Mathematica
DictionaryLookup[All]
{"Arabic", "BrazilianPortuguese", "Breton", "BritishEnglish",
"Catalan", "Croatian", "Danish", "Dutch", "English", "Esperanto",
"Faroese", "Finnish", "French", "Galician", "German", "Hebrew",
"Hindi", "Hungarian", "IrishGaelic", "Italian", "Latin", "Polish",
"Portuguese", "Russian", "ScottishGaelic", "Spanish", "Swedish"}
as well as how to get a list of the form {language,number of words in dictionary}
wordsInLanguage[lang_] := {lang, Length[DictionaryLookup[{lang, All}]]}
wordsInLanguage["Russian"]
{"Russian", 31801}
so you can just use Map to get what your need in (a):
Map[wordsInLanguage, DictionaryLookup[All]]
{{"Arabic", 43768}, {"BrazilianPortuguese", 264713}, {"Breton",
32733}, {"BritishEnglish", 86135}, {"Catalan", 602208}, {"Croatian",
260752}, {"Danish", 376469}, {"Dutch", 229368}, {"English",
92518}, {"Esperanto", 14780}, {"Faroese", 108508}, {"Finnish",
728498}, {"French", 139657}, {"Galician", 515385}, {"German",
76155}, {"Hebrew", 455264}, {"Hindi", 15983}, {"Hungarian",
230206}, {"IrishGaelic", 65203}, {"Italian", 116854}, {"Latin",
8777}, {"Polish", 234907}, {"Portuguese", 459996}, {"Russian",
31801}, {"ScottishGaelic", 15670}, {"Spanish", 86016}, {"Swedish",
121430}}
D. Flattening lists. Now, to answer your second question, you need to learn how to flatten lists. For example, given a list {1, 2}
, how can you get a list {1, 2, 3}
?
There are quite a few ways:
(* works if you know that the list only contains two elements *)
addThirdElement[list_, element_] := {list[[1]], list[[2]], element}
addThirdElement[{1, 2}, 3]
{1, 2, 3}
Another option is this - you can even reorder elements in the list:
addThirdElement1[{first_, second_}, third_] := {third, second, first}
addThirdElement1[{1, 2}, 3]
{3, 2, 1}
There are many more - e.g. look up Flatten
in Mathematica documentation.
That should give you enough to solve the last part. Good luck!