Введение в систему Mathmatica 3.0

         

Mathematica может оперироватьне только с числами, но и с данными любого типа.


Считывание всех элементов словаря.

data=ReadList["dictionary.dat",String];

Выбор первых 40 слов в словаре.

Take[data,40] {"a","AAA","AAAS","Aarhus","Aaron","ABA","Ababa", "aback","abacus","abalone","abandon","abase","abash", "abate","abbas","abbe","abbey","abbot","Abbott", "abbreviate","abc","abdicate","abdomen","abdominal", "abduct","Abe","abed","Abel","Abelian","Abelson", "Aberdeen","Abernathy","aberrant","aberrate", "abet","abetted","abetting","abeyance","abeyant", "abhorred"}

Выбор слов, которые являются палиндромами и содержат более двух букв.

Select[data,(#==StringReverse[#] && StringLength[#]>2)&] {"AAA","ABA","ala","AMA","ana","bib","bob","bub","CDC", "civic","dad","deed","did","DOD","dud","eke","ere", "eve","ewe","eye","gag","gig","gog","huh","iii", "level","madam","minim","mum","non","noon","nun","pap", "PDP","peep","pep","pip","poop","pop","pup","radar", "refer","rever","rotor","sis","s's","tat","teet", "tenet","tit","TNT","toot","tot","wow"}

Эта команда находит длины всех слов в словаре.



wordLengths=Map[StringLength,data];

Подсчет общего числа слов равной длины.


Table[Count[wordLengths,i],{i,Max[wordLengths]}]{26,131,775,2152,3093,3793,3929,3484,2969,1883,1052, 542,260,102,39,15,6,4,0,1,2,1}
График распределения количества слов в словаре по длинам.

ListPlot[%,PlotStyle->PointSize[0.02]];
Предыдущая глава Оглавление Следующая глава


Содержание раздела