Compare commits

...
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.

1 Commits

Author SHA1 Message Date
Alexander Zhirov ef8298407a example 6 2021-11-09 22:06:20 +03:00
4 changed files with 4513 additions and 0 deletions

15
src/example_6/.gitignore vendored Normal file
View File

@ -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

9
src/example_6/dub.json Normal file
View File

@ -0,0 +1,9 @@
{
"authors": [
"alexander"
],
"description": "Подсчет частот. Лямбда-функции.",
"license": "proprietary",
"name": "example_6",
"targetPath": "bin"
}

View File

@ -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