Key and value with ranges

Imperatorn johan_forsberg_86 at hotmail.com
Mon Oct 2 06:19:29 UTC 2023


On Monday, 2 October 2023 at 02:47:37 UTC, Joel wrote:
> ```d
> import std;
>
> auto data=“I went for a walk, and fell down a hole.”;

You can improve it further by inlining

```d
import std;

auto data = "I went for a walk, and fell down a hole.";

void main(string[] args)
{
     int[string] dic;

     data.split(' ').each!(w => dic[w]++);
     sort(dic.keys).each!(w => writeln(dic[w], " ",w));
}
```


More information about the Digitalmars-d-learn mailing list