how to return map(fn)

steve stevethe1st at gmail.com
Tue Feb 22 13:53:34 UTC 2022


On Monday, 21 February 2022 at 23:07:44 UTC, Ali Çehreli wrote:
> On 2/21/22 12:44, steve wrote:
>...


thanks for your help. I'm unfortunately still a bit confused. 
Maybe I wasn't clear or maybe I'm just missing something here. 
What I was trying to return is function that can then be applied 
to e.g. an array. As I understand the mapped function you wrote 
expects a range and a function argument something that would let 
me do


```
float my_function(float x){ return 2*x;}

auto my_function_mapped = mapped(my_function);
assert(my_function_mapped([1.,2.,3.]) == [2.,4.,6.]);

```


More information about the Digitalmars-d-learn mailing list