Hello,

D-Language allows for anonymous functions.
Is there a way of elegant partial function application such as in other (functional) languages?
A function "doemar" accepts a function with one parameter,
Another function g defined within mail accepts two parameters and should be applied partially. I found a way but it requires a temporary lambda expression in the invocation.
Is there a better way to do this?

```d
    void doemar( int delegate(int y) f)
    {
       for(int i=0;i<3;i++) writeln( f(i));
    }


    void main()
    {

       int delegate(int x,int y) g;
       for (int i=0;i<3;i++)
       {
          g = (a,b) => i*10+ a*3+b;

          writeln("---------");
          doemar( (x) => g(x,i));
       }
    }
```
Thanks
  • Partial function... atzensepp via Digitalmars-d-learn
    • Re: Partial... Christian Köstlin via Digitalmars-d-learn
    • Re: Partial... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: Par... atzensepp via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
          • ... atzensepp via Digitalmars-d-learn

Reply via email to