This repository has been archived on 2021-11-27. You can view files and clone it, but cannot push or open issues or pull requests.
4 changed files with
4513 additions and
0 deletions
|
|
|
@ -0,0 +1,15 @@
|
|
|
|
|
.dub
|
|
|
|
|
docs.json
|
|
|
|
|
__dummy.html
|
|
|
|
|
docs/
|
|
|
|
|
/example_6
|
|
|
|
|
example_6.so
|
|
|
|
|
example_6.dylib
|
|
|
|
|
example_6.dll
|
|
|
|
|
example_6.a
|
|
|
|
|
example_6.lib
|
|
|
|
|
example_6-test-*
|
|
|
|
|
*.exe
|
|
|
|
|
*.o
|
|
|
|
|
*.obj
|
|
|
|
|
*.lst
|
|
|
|
@ -0,0 +1,9 @@
|
|
|
|
|
{
|
|
|
|
|
"authors": [
|
|
|
|
|
"alexander"
|
|
|
|
|
],
|
|
|
|
|
"description": "Подсчет частот. Лямбда-функции.",
|
|
|
|
|
"license": "proprietary",
|
|
|
|
|
"name": "example_6",
|
|
|
|
|
"targetPath": "bin"
|
|
|
|
|
}
|
|
|
|
@ -0,0 +1,26 @@
|
|
|
|
|
import std.stdio, std.string, std.algorithm;
|
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
|
{
|
|
|
|
|
// auto f = File("./src/example_6/source/hamlet.txt", "r");
|
|
|
|
|
auto f = File("./source/hamlet.txt", "r");
|
|
|
|
|
|
|
|
|
|
uint[string] freqs;
|
|
|
|
|
foreach (line; f.byLine)
|
|
|
|
|
{
|
|
|
|
|
foreach (word; strip(line).split())
|
|
|
|
|
{
|
|
|
|
|
++freqs[word.idup];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string[] words = freqs.keys;
|
|
|
|
|
sort!((a, b) {
|
|
|
|
|
return freqs[a] < freqs[b];
|
|
|
|
|
}) (words);
|
|
|
|
|
|
|
|
|
|
foreach (word; words)
|
|
|
|
|
{
|
|
|
|
|
writefln("%6u\t%s", freqs[word], word);
|
|
|
|
|
}
|
|
|
|
|
}
|
File diff suppressed because it is too large
Load Diff