Coding Challenges - Dlang or Generic

Salih Dincer salihdb at hotmail.com
Tue Jan 10 13:12:45 UTC 2023


On Tuesday, 10 January 2023 at 10:58:37 UTC, matheus wrote:
> On Tuesday, 10 January 2023 at 07:38:31 UTC, Salih Dincer wrote:
>> You don't need validDate.  Because there is daysInMonth:
>
> That's really better. thanks for the info.
>

Actually, I should thank you. When I first wrote these codes, I 
couldn't shorten them that much. Because I've done fun things 
like this. I think you will like EnumPrint():

```d
     auto enumPrint(T)(size_t len = 0)
     {
       int[string] result; int i = 1;
       for(T x = T.min; x <= T.max; x++)
       {
         result[len ? x.to!string[0..len]
                    : x.to!string] = i++;
       }
       return result;
     }
     enumPrint!DayOfWeek(3).writeln;
}
```
Thank you...

SDB at 79


More information about the Digitalmars-d-learn mailing list