Function Composition

atzensepp webwicht at web.de
Thu Jan 25 18:44:26 UTC 2024


On Thursday, 25 January 2024 at 12:19:47 UTC, Paul Backus wrote:
> On Thursday, 25 January 2024 at 08:25:02 UTC, atzensepp wrote:
>> ```d
>>   int function(int) t = compose!(f,g,g,f,g,g,f,g,g,f);
>> ```
>>
>> This leads to:
>> ```
>> gdc lambda4.d
>> lambda4.d:28:25: error: template compose(E)(E a) has no value
>>    int function(int) t = compose!(f,g,g,f,g,g,f,g,g,f);
>>
>> ```
>
> Try using the address operator:
>
>     //                  Here
>     //                    ▼
>     int function(int) t = &compose!(f,g,g,f,g,g,f,g,g,f);
Hello,
thanks for the hint. But in my environment I am getting the same 
error:
```
gdc lambda4.d
lambda4.d:29:26: error: compose(E)(E a) is not an lvalue
    int function(int) t = &compose!(f,g,g,f,g,g,f,g,g,f);

```

However this works:
```d
   int delegate (int) td = (x) => compose!(f,g,g,f,g,g,f,g,g,f)(x);

```


More information about the Digitalmars-d-learn mailing list