Tuple List

Sergey kornburn at yandex.ru
Wed Sep 4 08:58:34 UTC 2024


On Wednesday, 4 September 2024 at 08:45:04 UTC, Salih Dincer 
wrote:
> On Wednesday, 4 September 2024 at 08:04:58 UTC, drug007 wrote:
> Thank you, it's my mistake. We confused HOF, which has the same 
> first letter. So, if we turn the question towards the 
> associative array, can a similar one be done without using each 
> or foreach? For example:
>
> ```d
> auto l2 = ["WC": 0, "Mutfak": 41,
>     "Salon": 42, "Atelye": 0
>   ];
>
>   l2.values.filter!"a > 0".writeln;
>   // [41, 42]
>   foreach(key, value; l2)
>     if(value > 0) key.write(", ");
>
>   // Mutfak, Salon,
> ```

Something like:
```d
l2.byPair.filter!"a.value > 0".map!(a => a.key).writeln;
```


More information about the Digitalmars-d-learn mailing list