Linked Questions

7 votes
3 answers
331 views

When submitting a function, can global variables be declared outside the function? [duplicate]

1. When submitting a function, can global variables be declared outside the function? For example, if I have the C code f(n){int a,b,c=4;dosomething;} am I ...
0 votes
0 answers
34 views

Function and Code [duplicate]

Is it allowed to have an answer which has some code outside of a function? For example, in Python, if you were to get the sum of two square roots, would this be allowed: ...
  • 521
24 votes
3 answers
3k views

Should submissions be allowed to exit with an error?

Suppose we have the following Python code: f=lambda x:x*2 X The first line defines a function which doubles a number. Then the second line is reached, is found ...
  • 61.1k
24 votes
3 answers
2k views

Do function submissions have to be reusable?

Simple question: if I answer a code golf with a function (for a task which is supposed to terminate), does the function actually have to be reusable? Or could it, say, modify some globals which break ...
24 votes
3 answers
982 views

On scoring builtin functions

Suppose there's a challenge which can be solved completely by a builtin function, and functions are allowed. Note that as of writing the standard loophole for builtins is heavily disputed, but let's ...
  • 61.1k
13 votes
2 answers
1k views

Unnamed Functions in Code Golf

For many code golf questions, we allow functions as answers. What exactly does it mean for some code to be a valid submission as a function? This question came up during a discussion on built-ins, ...
  • 41.4k
11 votes
1 answer
232 views

Functions throwing exceptions: an exception to the rules?

I'm seeking greater clarity around whether we currently allow functions to throw exceptions, and if so, under what circumstances. There seem to be contradictory posts on this topic—several highly ...
  • 10.7k
5 votes
1 answer
508 views

Zsh: Functions and Math functions

I have been using functions for Zsh submissions for some time. I typically submit the body alone, as the body can be run as a full program with no modification: ...
7 votes
0 answers
253 views

Does code need to be 100% syntactically correct? [duplicate]

I've come across the following answer in a code-golf challenge in Haskell, where one has to provide a function: <bindings> <expression> Now, the last ...
  • 701
1 vote
0 answers
59 views

Function not that directly used allowed? [duplicate]

In this answer, the function is defined as With(Math)f=(a,b,c,d)=>... (1) However, f is not used in the function, so it ...
  • 13k