If I'm not mistaken, (my search has failed me), a unnamed function literal answer is defined along the lines of
a block of code that evaluates to a callable value
So, if your submission is
<code>
You should be able to do one of the following (structures) to run your answer:
<type> <result> = (<code>).call(<params>);
<type> <name> = <code>;
<type> <result> = <name>.call(<params>);
Or, as a function answer, adding your code should (in a language-defined way) provide a callable binding which solves the problem.
In Python, f=lambda ...
works because after its execution, a binding f
exists which is a reusable callable binding which solves the question.
In C-like languages, <type> f() { ... }
works because after its inclusion in a source file, a callable binding f
exists which is a reusable solution to the question.
In Java/C# though, we've run into the issue of typing with our unnamed function. As in the related issue about typing lambdas, we allow just the literal because the question itself gives the context to infer the required type of the binding, and it's more consistent with other languages' scoring.
However, I don't think this should extend to when the function needs to be named. At that point, you are no longer submitting an answer as an unnamed function, but as a block of code that after inclusion defines a function binding.
f=<lambda>
means nothing in C#. You need to provide a type to create a name binding in C#.
I think C# has an opinion on this as well:
Cannot assign lambda expression to an implicitly-typed variable
I was going to suggest the use of var
, but C# disallows that, likely because of the discussed issues about typing a lambda.
My position is that if you need to name the function submission, you need to provide a proper function submission, that is: code that, when included, defines a callable name binding which can be used to solve the question.
An unnamed function expression needs to be that: an unnamed function expression that I assign to a variable (and thus take the typing responsibility).
TL;DR this shouldn't be an allowed submission format, use a proper function declaration if you need to call it.
I agree with the summary in this answer, with the extension of allowing combining any number of defined functions with one anonymous function which is the submission.
TL;DR TL;DR: Oliver's answer expresses the same sentiment and I agree with it fully.
f=(<params>)=><do_something_recursive>
many times... And I never saw someone complaining about it... \$\endgroup\$