On 21/01/2024 9:55 AM, atzensepp wrote:
import std.stdio; // Overloads are resolved when the partially applied function is called // with the remaining arguments. struct S { static char fun(int i, string s) { return s[i]; } static int fun(int a, int b) { return a * b; } } void main() { alias fun3 = partial!(S.fun, 3); writeln(fun3("hello")); // 'l' writeln(fun3(10)); // 30 }

This worked:

```d
import std.functional;
import std.stdio;

// Overloads are resolved when the partially applied function is called
// with the remaining arguments.
struct S
{
    static char fun(int i, string s)
    {
        return s[i];
    }

    static int fun(int a, int b)
    {
        return a * b;
    }
}

void main()
{
    alias fun3 = partial!(S.fun, 3);
    writeln(fun3("hello")); // 'l'
    writeln(fun3(10)); // 30
}
```
  • 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