Here is my definition of a function:
 
 1. A function must have the ability to be called by its name, object, reference, or other handle (this prevents code snippets). The only exception to this is the main method (or equivalent) of a program.
 2. A function must have its own scope
 3. A function must be able to accept parameters and return values without the use of variables outside the scope of the function.
 4. If a function can be compiled, interpreted, or otherwise executed in a non-REPL environment without any modification, it is a full program (note that in some languages, the main method can be both a function and a full program).
 5. Multiple functions can be counted as one function, provided that each helper function meets the 4 previous conditions.

For an example, let's look at Java lambda expressions.

 1. You can assign a lambda expression to an object, so it passes the handle test.
 2. A lambda expression has its own scope.
 3. It is possible to write a lambda expression that accepts parameters and returns values.

For example:

    (int a, double b)->{
        return 4;
    }

   
Since a lambda that satisfies #3 exists, any lambda is considered a function, even those that don't accept parameters:

    ()->{
        System.out.println("Lambda is running");
    }

 4. If I save either of the programs above as `Lambda.java`, it certainly doesn't compile.
 5. N/A

I made a quick flowchart to categorize various bits of code (sorry for my lack of flowcharting skills):

[![A flowchart][1]][1]


  [1]: https://i.sstatic.net/8WudB.png