subfunction
A subfunction is a function defined within another function or scope to perform a small, well-scoped task. The concept is most often associated with programming languages that support nested or inner functions, such as Python, JavaScript, and Lisp. A subfunction can typically access variables from its enclosing scope, forming a closure, and is usually not accessible from outside the outer function unless it is explicitly exposed or returned.
In typical use, subfunctions help break complex logic into simpler parts, improve readability, and reduce duplication
In languages that do not support nested definitions, a closely related concept is a private helper function
In mathematics and formal analysis, the term subfunction is less standardized. It can be used informally to
Example (Python): def outer(x): def inner(y): return y*y; return inner(x) + 1. This illustrates a subfunction defined