toLower
Joel
joelcnz at gmail.com
Thu Aug 17 09:28:05 UTC 2023
On Wednesday, 16 August 2023 at 05:40:09 UTC, FeepingCreature
wrote:
> On Tuesday, 15 August 2023 at 20:09:28 UTC, Joel wrote:
>> On Tuesday, 15 August 2023 at 16:54:49 UTC, FeepingCreature
>> wrote:
>>> But does *not* import `std.ascii`! So there's no ambiguity
>>> inside the `sort` string expression between the two `toLower`
>>> functions..
>>
>> How do I get it to work?
>>
>> I tried std.ascii.toLower. And using alias
>> toLower=std.ascii.toLower;
>
> To elaborate more, `toLower` doesn't work because
> function-scope aliases are not considered for UFCS.
>
> ```
> alias toLower = std.ascii.toLower;
>
> ...
> // So this does actually work:
> .map!toLower
> // but this does not, because it looks for a UFCS-capable
> symbol
> .map!(c => c.toLower)
> // but this does again
> .map!(c => toLower(c))
>
> ```
I get an compile time error with sort after using toLower,
putting in array before sort, didn’t work:
```d
void main() {
Import std;
"EzraTezla"
.to!(char[])
.byCodeUnit
.map!(std.uni.toLower)
.sort!"a<b"
.writeln;
}
```
onlineapp.d(8): Error: none of the overloads of template
`std.algorithm.sorting.sort` are callable using argument types
`!("a<b")(MapResult!(toLower, ByCodeUnitImpl))`
/dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/sorting.d(1925): Candidate is: `sort(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable, Range)(Range r)`
with `less = "a<b",
ss = SwapStrategy.unstable,
Range = MapResult!(toLower, ByCodeUnitImpl)`
must satisfy one of the following constraints:
` hasSwappableElements!Range
hasAssignableElements!Range
ss != SwapStrategy.unstable`
More information about the Digitalmars-d-learn
mailing list