Skip to main content
Post Closed as "Duplicate" by Nathan Merrill, flawr, Ismael Miguel, user8397947, DJMcMayhem
added 7 characters in body
Source Link
FlipTack
  • 14.7k
  • 23
  • 16

Submission formats are always flexible here on PPCG. Named functions, anonymous functions or even full programs that perform IO, are all fine.

Even currying is acceptable, for example, taking arguments as f(4)(5) rather than f(4, 5).

But what about returning a function that returns the result?


Examples

Consider the following Python code to find the length of a string:

f = lambda s: s.__len__

I know this is a long way to do it, I'm just trying to give a simple example.

To call this function, one would have to call f with the string parameter, and then call the result, to get the answer - for example, f("String")().

Another example is this Javapseudo-Java lambda to convert an object to a string:

x -> x.toString

If you assigned this to f, you'd call it with f(object)(). It's very similar to currying, except that the second call takes no parameter.


My question is - should we allow this as an acceptable output format for PPCG code-golf answers?

Submission formats are always flexible here on PPCG. Named functions, anonymous functions or even full programs that perform IO, are all fine.

Even currying is acceptable, for example, taking arguments as f(4)(5) rather than f(4, 5).

But what about returning a function that returns the result?


Examples

Consider the following Python code to find the length of a string:

f = lambda s: s.__len__

I know this is a long way to do it, I'm just trying to give a simple example.

To call this function, one would have to call f with the string parameter, and then call the result, to get the answer - for example, f("String")().

Another example is this Java lambda to convert an object to a string:

x -> x.toString

If you assigned this to f, you'd call it with f(object)(). It's very similar to currying, except that the second call takes no parameter.


My question is - should we allow this as an acceptable output format for PPCG code-golf answers?

Submission formats are always flexible here on PPCG. Named functions, anonymous functions or even full programs that perform IO, are all fine.

Even currying is acceptable, for example, taking arguments as f(4)(5) rather than f(4, 5).

But what about returning a function that returns the result?


Examples

Consider the following Python code to find the length of a string:

f = lambda s: s.__len__

I know this is a long way to do it, I'm just trying to give a simple example.

To call this function, one would have to call f with the string parameter, and then call the result, to get the answer - for example, f("String")().

Another example is this pseudo-Java lambda to convert an object to a string:

x -> x.toString

If you assigned this to f, you'd call it with f(object)(). It's very similar to currying, except that the second call takes no parameter.


My question is - should we allow this as an acceptable output format for PPCG code-golf answers?

added 92 characters in body
Source Link
FlipTack
  • 14.7k
  • 23
  • 16

Submission formats are always flexible here on PPCG. Named functions, anonymous functions or even full programs that perform IO, are all fine.

Even currying is acceptable, for example, taking arguments as f(4)(5) rather than f(4, 5).

But what about returning a function that returns the result?


Examples

Consider the following Python code to find the length of a string:

f = lambda s: s.__len__

I know this is a long way to do it, I'm just trying to give a simple example.

To call this function, one would have to call f with the string parameter, and then call the result, to get the answer - for example, f("String")().

Another example is this Java lambda to convert an object to a string:

x -> x.toString

If you assigned this to f, you'd call it with f(object)(). It's very similar to currying, except that the second call takes no parameter.


My question is - should we allow this as an acceptable output format for PPCG code-golf answers?

Submission formats are always flexible here on PPCG. Named functions, anonymous functions or even full programs that perform IO, are all fine.

Even currying is acceptable, for example, taking arguments as f(4)(5) rather than f(4, 5).

But what about returning a function that returns the result?


Examples

Consider the following Python code to find the length of a string:

f = lambda s: s.__len__

To call this function, one would have to call f with the string parameter, and then call the result, to get the answer - for example, f("String")().

Another example is this Java lambda to convert an object to a string:

x -> x.toString

If you assigned this to f, you'd call it with f(object)(). It's very similar to currying, except that the second call takes no parameter.


My question is - should we allow this as an acceptable output format for PPCG code-golf answers?

Submission formats are always flexible here on PPCG. Named functions, anonymous functions or even full programs that perform IO, are all fine.

Even currying is acceptable, for example, taking arguments as f(4)(5) rather than f(4, 5).

But what about returning a function that returns the result?


Examples

Consider the following Python code to find the length of a string:

f = lambda s: s.__len__

I know this is a long way to do it, I'm just trying to give a simple example.

To call this function, one would have to call f with the string parameter, and then call the result, to get the answer - for example, f("String")().

Another example is this Java lambda to convert an object to a string:

x -> x.toString

If you assigned this to f, you'd call it with f(object)(). It's very similar to currying, except that the second call takes no parameter.


My question is - should we allow this as an acceptable output format for PPCG code-golf answers?

Source Link
FlipTack
  • 14.7k
  • 23
  • 16

Returning a function, which returns the result?

Submission formats are always flexible here on PPCG. Named functions, anonymous functions or even full programs that perform IO, are all fine.

Even currying is acceptable, for example, taking arguments as f(4)(5) rather than f(4, 5).

But what about returning a function that returns the result?


Examples

Consider the following Python code to find the length of a string:

f = lambda s: s.__len__

To call this function, one would have to call f with the string parameter, and then call the result, to get the answer - for example, f("String")().

Another example is this Java lambda to convert an object to a string:

x -> x.toString

If you assigned this to f, you'd call it with f(object)(). It's very similar to currying, except that the second call takes no parameter.


My question is - should we allow this as an acceptable output format for PPCG code-golf answers?