E.g. requiring to call by f(4), and add 1 to the byte count

Or maybe when inputting a choice, require input f`!#%` or f`&^%`, and add 6 to the byte count?(Related)

Cuz we allow filename storage as long as its byte counted(Related)

  • \$\begingroup\$ No. We don't allow filename storage either. Also, this looks like JS; declaring variables is like 3 extra bytes... \$\endgroup\$ – ASCII-only Mar 12 '18 at 1:51
  • \$\begingroup\$ codegolf.meta.stackexchange.com/a/1072/76323 don't allow only when not count bytes \$\endgroup\$ – l4m2 Mar 12 '18 at 1:55
  • \$\begingroup\$ Hmm, I guess that's true. But yeah, you're not allowed to assume the user inputs part of the data for you when they're calling the function. \$\endgroup\$ – ASCII-only Mar 12 '18 at 2:15
  • 2
    \$\begingroup\$ A comment doesn't really work as a consensus, even if it's got many votes (comments can't be downvoted). Can you provide another answer/meta post for that? \$\endgroup\$ – Rɪᴋᴇʀ Mar 12 '18 at 2:36
  • 2
    \$\begingroup\$ It's not very clear what you're asking. \$\endgroup\$ – Peter Taylor Mar 12 '18 at 16:28

In some cases

In programming languages where functions are curried by default this is already allowed. For example here I define the function % as so:


but my actual solution requires the empty string to be passed as input. I add the bytes


(if you are not familiar with Haskell this partially applies % to the empty string) to create a anonymous function. This is basically passing a static argument to the function from earlier. It is even clearer if we rename % to f:

f a c@(e:d)=maximum[a!c,f""d,f(a++[e])d]
f _ _=0

In which case we add the extra bytes


Since anonymous functions are already allowed, and partial application create returns a function, this is allowed and the way to count bytes is rather obvious.

This only works if the original function was named (not anonymous) because it has to be called. If my function were already anonymous I would have to add to its definition or name it.

But not in other cases

If your function is not curried, it can't use the same format. Alternative solutions would include

  • Define a new function (anonymous or named) that calls on the old one (assuming the old one was named).
  • If your function is not recursive, you could also pay to define a new constant with the value you wish to access.
  • If your language has a builtin way to do partial application you could do that to create a new anonymous function.
  • 1
    \$\begingroup\$ (that is equivalent to "no, the submission must be a function" + "function submission can be anonymous) \$\endgroup\$ – user202729 Mar 12 '18 at 11:05
  • \$\begingroup\$ @user202729 Not that same. It seems allow to reduce a pair of () \$\endgroup\$ – l4m2 Mar 12 '18 at 15:02
  • \$\begingroup\$ @l4m2 Haskell doesn't use () for function calls. user202729 is correct. \$\endgroup\$ – Post Rock Garf Hunter Mar 12 '18 at 15:34
  • \$\begingroup\$ If you didn't point exact language and say "sometimes" \$\endgroup\$ – l4m2 Mar 12 '18 at 15:35
  • \$\begingroup\$ @l4m2 I'm not sure what you are trying to say. Haskell is an example of a language that supports partial application, JavaScript also supports partial application on curried functions. This answer is not specific to Haskell if that is what you mean. \$\endgroup\$ – Post Rock Garf Hunter Mar 12 '18 at 17:34

Not the answer you're looking for? Browse other questions tagged .