On Wednesday, 17 January 2024 at 16:54:00 UTC, H. S. Teoh wrote:
On Wed, Jan 17, 2024 at 07:57:02AM -0800, H. S. Teoh via
Digitalmars-d-learn wrote: [...]
I'll push the code to github.
[...]
Here:
https://github.com/quickfur/prechelt/blob/master/encode_phone.d
T
BTW here's you main function so it can run on the benchmark:
```d
int main(string[] args)
{
bool countOnly = args.length > 1 ? (() {
final switch (args[1])
{
case "count":
return true;
case "print":
return false;
}
})() : false;
auto dictfile = args.length > 2 ? args[2] : "tests/words.txt";
auto input = args.length > 3 ? args[3] : "tests/numbers.txt";
Trie dict = loadDictionary(File(dictfile).byLine);
if (countOnly)
{
size_t count;
encodePhoneNumbers(File(input).byLine, dict, (phone,
match) { count++; });
writefln("%d", count);
}
else
{
encodePhoneNumbers(File(input).byLine, dict, (phone,
match) {
writefln("%s: %s", phone, match);
});
}
return 0;
}
```