Obsecure problem 2
pascal111
judas.the.messiah.111 at gmail.com
Wed Aug 3 18:33:37 UTC 2022
On Wednesday, 3 August 2022 at 18:25:50 UTC, jfondren wrote:
> On Wednesday, 3 August 2022 at 17:33:40 UTC, pascal111 wrote:
>> On Wednesday, 3 August 2022 at 17:09:11 UTC, jfondren wrote:
>>> On Wednesday, 3 August 2022 at 16:59:53 UTC, pascal111 wrote:
>>>> I tried to make a template that receive lambda expression to
>>>> apply it on a given range the user specifies, but I found
>>>> non-understood problem:
>>>
>>> Compare with:
>>>
>>> ```D
>>> auto foo(Range)(Range range) { // remove isInputRange!T test
>>> ...
>>> lolo.foo!(a=>a+2); // call foo!(f)() rather than
>>> foo!()(f)
>>> ```
>>
>> Ok! the program ran and gives "[12, 66, 654, -98, 54]" without
>> adding "2" as I requested!! why?!
>
> You call notfunny(x) in a loop, discarding the result of the
> addition.
I changed it to "x=notfunny(x);" and has the same result.
More information about the Digitalmars-d-learn
mailing list