Functions
Map
Arrows point from what you learn first to what it opens. Point at a concept to light up its chain and where it comes back deeper. Right-click a concept (or press and hold it) for its lessons and stories.
- Proven to depth123
- Open
- Locked
- Comes back deeper
Learning path
In the order the concepts build on each other.
- Functions in codeLockedNamed, reusable blocks of code that take inputs (parameters) and produce outputs (return values).Opens after: Input and output
- First-class functionsLockedFunctions are values like any other - they can be named, passed to other functions, returned and stored - which lets one function hold a pattern of work and take the details from outside.Opens after: Lists, Functions in code
- RecursionLockedA function that solves a problem by calling itself on a smaller version of the same problem, until it reaches a base case.Opens after: Functions in code, Conditionals, Nested data
- Return valuesLockedThe value a function hands back to the code that called it, with return, so its answer can be stored, added or passed on - unlike print, which only shows it on the screen.Opens after: Functions in code
- ScopeLockedWhere in a program a name can be used - names made inside a function are local to it, so functions can't trip over each other's names.Opens after: Return values
- DecompositionLockedSplitting a task into smaller named steps, each small enough to write and check on its own, so a big program reads as a story of calls.Opens after: Scope
Connections to other domains
- Functions in code leads to GoroutinesConcurrency
- Recursion leads to LoopsControl Flow
- Recursion needs ConditionalsControl Flow
- Recursion needs Nested dataData Structures
- Functions in code leads to PointersData Types
- Functions in code, depth 2 needs FunctionsAlgebra
- Functions in code needs Input and outputProgram Basics
- First-class functions leads to SortingAlgorithms
- Functions in code leads to ConcurrencyConcurrency
- Return values leads to BooleansControl Flow
- First-class functions leads to ComprehensionsData Structures
- Return values leads to NoneData Types
- Decomposition, depth 2 needs Classes and objectsObjects and Classes
- Decomposition, depth 2 needs TestingWriting Correct Code
- First-class functions needs ListsData Structures
- Functions in code leads to Classes and objectsObjects and Classes
- Functions in code leads to Modules and importsOrganizing Programs
- Functions in code leads to ExceptionsWriting Correct Code