<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://staging.moocwiki.org/index.php?action=history&amp;feed=atom&amp;title=English%3AFunctional_Programming_Concepts</id>
	<title>English:Functional Programming Concepts - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://staging.moocwiki.org/index.php?action=history&amp;feed=atom&amp;title=English%3AFunctional_Programming_Concepts"/>
	<link rel="alternate" type="text/html" href="https://staging.moocwiki.org/index.php?title=English:Functional_Programming_Concepts&amp;action=history"/>
	<updated>2026-09-04T03:38:02Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in MOOCsWiki Staging</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://staging.moocwiki.org/index.php?title=English:Functional_Programming_Concepts&amp;diff=47961&amp;oldid=prev</id>
		<title>Glanz: aiMOOC über GPT aiMOOC Action erstellt</title>
		<link rel="alternate" type="text/html" href="https://staging.moocwiki.org/index.php?title=English:Functional_Programming_Concepts&amp;diff=47961&amp;oldid=prev"/>
		<updated>2026-08-29T12:25:51Z</updated>

		<summary type="html">&lt;p&gt;aiMOOC über GPT aiMOOC Action erstellt&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{T}}&lt;br /&gt;
[[Category:English]]&lt;br /&gt;
[[Category:Functional Programming Concepts]]&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Functional programming&amp;#039;&amp;#039;&amp;#039; is a programming paradigm that builds computations by applying and composing functions. Instead of describing a program mainly as a sequence of commands that repeatedly change shared state, functional programming encourages you to describe transformations from inputs to outputs. This approach can make programs easier to reason about, test, combine, and run safely in parallel.&lt;br /&gt;
&lt;br /&gt;
This aiMOOC is designed for &amp;#039;&amp;#039;&amp;#039;Grades 11–13&amp;#039;&amp;#039;&amp;#039;. You should already understand basic variables, expressions, conditions, lists, and functions. You do not need previous experience with Haskell. Haskell is used here because its syntax makes important functional ideas especially visible, but the concepts also appear in languages such as [[English:Python|Python]], [[English:JavaScript|JavaScript]], [[English:Scala|Scala]], [[English:F Sharp|F Sharp]], [[English:Clojure|Clojure]], [[English:Elixir|Elixir]], and many others.&lt;br /&gt;
&lt;br /&gt;
[[File:Haskell-Logo.svg|420px|frameless|center]]&lt;br /&gt;
&lt;br /&gt;
By the end of the course, you should be able to explain and apply [[English:Pure function|pure functions]], [[English:Immutable object|immutability]], [[English:Higher-order function|higher-order functions]], [[English:Recursion|Recursion]], [[English:Function composition|Function composition]], [[English:Lazy evaluation|Lazy evaluation]], and basic ideas from the [[English:Lambda calculus|Lambda calculus]]. You should also be able to compare functional and imperative solutions and justify when each style is useful.&lt;br /&gt;
&lt;br /&gt;
{{#ev:youtube|https://www.youtube.com/watch?v=LnX3B9oaKzw|500|center}}&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Functions as the Main Building Blocks =&lt;br /&gt;
&lt;br /&gt;
In mathematics, a function associates inputs with outputs. Functional programming takes this idea seriously: functions are treated as central program values, not merely as named blocks of instructions.&lt;br /&gt;
&lt;br /&gt;
[[File:CPT functional basics.svg|500px|frameless|center]]&lt;br /&gt;
&lt;br /&gt;
A simple function can be understood as a transformation. If a function called &amp;#039;&amp;#039;double&amp;#039;&amp;#039; receives 4 and returns 8, the important question is not which memory cell changed but which result follows from the given input.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;haskell&amp;quot;&amp;gt;&lt;br /&gt;
double :: Int -&amp;gt; Int&lt;br /&gt;
double x = x * 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The type declaration says that &amp;#039;&amp;#039;double&amp;#039;&amp;#039; takes an integer and returns an integer. Evaluating &amp;#039;&amp;#039;double 4&amp;#039;&amp;#039; produces 8.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== Pure Functions ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;pure function&amp;#039;&amp;#039;&amp;#039; has two key properties. First, the same input produces the same output. Second, evaluating the function does not create an observable side effect such as changing a global variable, modifying a shared data structure, printing to the screen, or writing to a file.&lt;br /&gt;
&lt;br /&gt;
For example, a function that calculates the area of a rectangle from width and height can be pure. A function that reads the current time is not pure in the same sense because its result can differ even when the explicit input is unchanged.&lt;br /&gt;
&lt;br /&gt;
Purity supports &amp;#039;&amp;#039;&amp;#039;referential transparency&amp;#039;&amp;#039;&amp;#039;: an expression can be replaced by its value without changing the meaning of the surrounding program. This makes local reasoning easier because you can study a function without tracing hidden changes elsewhere.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== Immutability ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Immutability&amp;#039;&amp;#039;&amp;#039; means that a value is not changed after it has been created. Instead of updating an existing list, a functional program commonly creates a new list that represents the desired result.&lt;br /&gt;
&lt;br /&gt;
Suppose the list is &amp;#039;&amp;#039;[2, 4, 6]&amp;#039;&amp;#039; and you want a version with 8 added. An immutable approach keeps the original list available and constructs a new list &amp;#039;&amp;#039;[2, 4, 6, 8]&amp;#039;&amp;#039;. Implementations may internally share data efficiently, so immutability does not necessarily mean copying every element.&lt;br /&gt;
&lt;br /&gt;
Immutability reduces problems caused by unexpected shared-state changes. This is especially helpful when several parts of a program use the same data or when tasks may execute concurrently.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= First-Class and Higher-Order Functions =&lt;br /&gt;
&lt;br /&gt;
In many functional languages, functions are &amp;#039;&amp;#039;&amp;#039;first-class values&amp;#039;&amp;#039;&amp;#039;. You can store them in variables or data structures, pass them as arguments, and return them from other functions.&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;higher-order function&amp;#039;&amp;#039;&amp;#039; is a function that takes one or more functions as arguments, returns a function, or both. Three common higher-order patterns are &amp;#039;&amp;#039;map&amp;#039;&amp;#039;, &amp;#039;&amp;#039;filter&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;fold&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== Map ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Map&amp;#039;&amp;#039; applies a function to every element of a collection and produces a collection of results.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;haskell&amp;quot;&amp;gt;&lt;br /&gt;
squares = map (\x -&amp;gt; x * x) [1, 2, 3, 4]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result is &amp;#039;&amp;#039;[1, 4, 9, 16]&amp;#039;&amp;#039;. The lambda expression &amp;#039;&amp;#039;\x -&amp;gt; x * x&amp;#039;&amp;#039; is an anonymous function.&lt;br /&gt;
&lt;br /&gt;
[[File:CPT Haskell Map function.svg|600px|frameless|center]]&lt;br /&gt;
&lt;br /&gt;
You can think of &amp;#039;&amp;#039;map&amp;#039;&amp;#039; as separating two decisions: &amp;#039;&amp;#039;&amp;#039;what transformation should happen&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;how that transformation is applied across the collection&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== Filter ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Filter&amp;#039;&amp;#039; keeps only elements that satisfy a predicate. A predicate is a function that produces a Boolean result.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;haskell&amp;quot;&amp;gt;&lt;br /&gt;
evens = filter even [1, 2, 3, 4, 5, 6]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result is &amp;#039;&amp;#039;[2, 4, 6]&amp;#039;&amp;#039;. The original list is not modified.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== Fold and Reduce ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;fold&amp;#039;&amp;#039;&amp;#039; combines the elements of a structure into a result by repeatedly applying a combining function. Many languages use the related name &amp;#039;&amp;#039;reduce&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;haskell&amp;quot;&amp;gt;&lt;br /&gt;
total = foldl (+) 0 [3, 5, 7]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The value starts at 0 and combines the list elements to produce 15.&lt;br /&gt;
&lt;br /&gt;
[[File:CPT fold function example.svg|500px|frameless|center]]&lt;br /&gt;
&lt;br /&gt;
Map, filter, and fold are powerful because they express common data-processing patterns without requiring you to write the control structure from scratch each time.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Lambda Expressions and the Lambda Calculus =&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;lambda expression&amp;#039;&amp;#039;&amp;#039; describes an anonymous function. In Haskell, &amp;#039;&amp;#039;\x -&amp;gt; x + 1&amp;#039;&amp;#039; means a function that takes &amp;#039;&amp;#039;x&amp;#039;&amp;#039; and returns &amp;#039;&amp;#039;x + 1&amp;#039;&amp;#039;. In Python, a similar idea can be written as &amp;#039;&amp;#039;lambda x: x + 1&amp;#039;&amp;#039;. JavaScript commonly uses an arrow function such as &amp;#039;&amp;#039;x =&amp;gt; x + 1&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
[[File:LambdaAbstraction.svg|600px|frameless|center]]&lt;br /&gt;
&lt;br /&gt;
The [[English:Lambda calculus|Lambda calculus]] is a formal system developed by Alonzo Church for expressing computation using function abstraction and application. Modern functional programming languages are not simply the untyped lambda calculus, but lambda-calculus ideas strongly influence how functions are represented and combined.&lt;br /&gt;
&lt;br /&gt;
Three useful ideas are:&lt;br /&gt;
# [[English:Abstraction|Abstraction]]: defining a function in terms of a parameter and an expression.&lt;br /&gt;
# [[English:Function application|Function application]]: applying a function to an argument.&lt;br /&gt;
# [[English:Substitution|Substitution]]: replacing a bound variable with an argument when evaluating an expression.&lt;br /&gt;
&lt;br /&gt;
{{#ev:youtube|https://www.youtube.com/watch?v=eis11j_iGMs|500|center}}&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Function Composition =&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Function composition&amp;#039;&amp;#039;&amp;#039; combines smaller functions so that the output of one becomes the input of another. If &amp;#039;&amp;#039;f&amp;#039;&amp;#039; and &amp;#039;&amp;#039;g&amp;#039;&amp;#039; are functions, the composition &amp;#039;&amp;#039;f after g&amp;#039;&amp;#039; means: first apply &amp;#039;&amp;#039;g&amp;#039;&amp;#039;, then apply &amp;#039;&amp;#039;f&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;haskell&amp;quot;&amp;gt;&lt;br /&gt;
addOne x = x + 1&lt;br /&gt;
double x = x * 2&lt;br /&gt;
transform = double . addOne&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Evaluating &amp;#039;&amp;#039;transform 3&amp;#039;&amp;#039; first gives &amp;#039;&amp;#039;addOne 3 = 4&amp;#039;&amp;#039; and then &amp;#039;&amp;#039;double 4 = 8&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
Composition encourages you to build programs from small, testable parts. It is similar to creating a pipeline in which each stage has a clear responsibility.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Recursion =&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Recursion&amp;#039;&amp;#039;&amp;#039; occurs when a function solves a problem by calling itself on a smaller or simpler case. A recursive definition needs a &amp;#039;&amp;#039;&amp;#039;base case&amp;#039;&amp;#039;&amp;#039; that stops the process and a &amp;#039;&amp;#039;&amp;#039;recursive case&amp;#039;&amp;#039;&amp;#039; that moves toward the base case.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;haskell&amp;quot;&amp;gt;&lt;br /&gt;
factorial 0 = 1&lt;br /&gt;
factorial n = n * factorial (n - 1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For &amp;#039;&amp;#039;factorial 4&amp;#039;&amp;#039;, the calls reduce the problem toward &amp;#039;&amp;#039;factorial 0&amp;#039;&amp;#039;. The results then combine to produce 24.&lt;br /&gt;
&lt;br /&gt;
In functional programming, recursion often replaces loops, although library functions such as &amp;#039;&amp;#039;map&amp;#039;&amp;#039;, &amp;#039;&amp;#039;filter&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;fold&amp;#039;&amp;#039; are usually clearer than writing explicit recursion for standard collection tasks.&lt;br /&gt;
&lt;br /&gt;
{{#ev:youtube|https://www.youtube.com/watch?v=Mv9NEXX1VHc|500|center}}&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Pattern Matching =&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Pattern matching&amp;#039;&amp;#039;&amp;#039; lets a function choose a definition based on the structure of its input. It is common in functional languages and works especially well with lists and algebraic data types.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;haskell&amp;quot;&amp;gt;&lt;br /&gt;
listLength [] = 0&lt;br /&gt;
listLength (_:xs) = 1 + listLength xs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first pattern matches an empty list. The second matches a non-empty list, ignores its first element, and recursively processes the remaining list.&lt;br /&gt;
&lt;br /&gt;
Pattern matching can make control flow closely match the structure of the data being processed.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Lazy Evaluation =&lt;br /&gt;
&lt;br /&gt;
With &amp;#039;&amp;#039;&amp;#039;lazy evaluation&amp;#039;&amp;#039;&amp;#039;, an expression is evaluated only when its result is needed. Haskell uses non-strict semantics and normally evaluates expressions lazily.&lt;br /&gt;
&lt;br /&gt;
This can make infinite data structures useful. For example, you can conceptually define an unending sequence of natural numbers and then request only its first ten values. The program does not need to construct the entire infinite sequence.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;haskell&amp;quot;&amp;gt;&lt;br /&gt;
naturals = [0..]&lt;br /&gt;
firstTen = take 10 naturals&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A delayed computation is often described as a &amp;#039;&amp;#039;&amp;#039;thunk&amp;#039;&amp;#039;&amp;#039;. Lazy evaluation can support modular programs and avoid unnecessary work, but it can also make performance and memory use less obvious if you do not understand when expressions are forced.&lt;br /&gt;
&lt;br /&gt;
[[File:Thunk-layers.png|450px|frameless|center]]&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Types and Functional Programming =&lt;br /&gt;
&lt;br /&gt;
Functional programming is not defined by a single type system. Some functional languages use strong static typing, while others use dynamic typing. Haskell uses static typing and type inference, which means the compiler can often determine types without requiring every type annotation to be written.&lt;br /&gt;
&lt;br /&gt;
Type signatures help communicate what a function can accept and return.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;haskell&amp;quot;&amp;gt;&lt;br /&gt;
isPositive :: Int -&amp;gt; Bool&lt;br /&gt;
isPositive x = x &amp;gt; 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A useful principle is that types can describe interfaces between functions. When you compose functions, compatible types help ensure that the output of one stage can become the input of the next.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Side Effects and Controlled Interaction =&lt;br /&gt;
&lt;br /&gt;
Real programs must interact with the world. They read input, display information, use networks, store files, and update databases. Functional programming does not eliminate these needs. Instead, functional languages provide ways to &amp;#039;&amp;#039;&amp;#039;separate pure transformations from effectful actions&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
Haskell makes this separation especially explicit through types such as &amp;#039;&amp;#039;IO&amp;#039;&amp;#039;. Other languages may use different mechanisms, but the architectural goal is similar: keep as much logic as practical pure and isolate effects at clear boundaries.&lt;br /&gt;
&lt;br /&gt;
This design can simplify testing. A pure function that transforms validated input into a result can be tested without opening files, connecting to a network, or changing global state.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Functional and Imperative Styles Compared =&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Imperative programming&amp;#039;&amp;#039;&amp;#039; often emphasizes commands and state changes: initialize a variable, update it in a loop, and stop when a condition is met. &amp;#039;&amp;#039;&amp;#039;Functional programming&amp;#039;&amp;#039;&amp;#039; often emphasizes expressions and transformations: map values, filter them, combine them, and compose functions.&lt;br /&gt;
&lt;br /&gt;
Neither style is automatically best for every problem. Many modern languages are multi-paradigm, so good programmers learn to choose ideas that make a particular task clear, reliable, and maintainable.&lt;br /&gt;
&lt;br /&gt;
A functional solution can be especially useful when:&lt;br /&gt;
# [[English:Data transformation|Data transformation]] is naturally described as a pipeline.&lt;br /&gt;
# [[English:Concurrency|Concurrency]] would be safer with less shared mutable state.&lt;br /&gt;
# [[English:Testing|Testing]] benefits from deterministic pure functions.&lt;br /&gt;
# [[English:Modularity|Modularity]] improves when complex behavior is composed from small functions.&lt;br /&gt;
&lt;br /&gt;
An imperative solution may be more direct when step-by-step state changes closely match the problem or when performance constraints require careful low-level control.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= From Expressions to Data Pipelines =&lt;br /&gt;
&lt;br /&gt;
Consider a list of temperatures in degrees Celsius. You want to keep only temperatures above freezing, convert them to Fahrenheit, and calculate an average.&lt;br /&gt;
&lt;br /&gt;
A functional approach can divide the task into transformations:&lt;br /&gt;
# Filter the list to keep values above zero.&lt;br /&gt;
# Map the conversion function across the remaining values.&lt;br /&gt;
# Fold or reduce the converted values to compute a total.&lt;br /&gt;
# Divide by the number of retained values.&lt;br /&gt;
&lt;br /&gt;
This pipeline can be read as a description of &amp;#039;&amp;#039;&amp;#039;what&amp;#039;&amp;#039;&amp;#039; happens to the data. Each stage can be tested independently.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Media Reflection =&lt;br /&gt;
&lt;br /&gt;
The following spoken recording provides another medium for reviewing the general topic of functional programming. As you listen, note which concepts overlap with the course and which ideas are presented with different terminology.&lt;br /&gt;
&lt;br /&gt;
[[File:En-Functional programming.ogg|center]]&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Interactive Tasks =&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== Quiz: Test Your Knowledge ==&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Which statement best describes a pure function?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(It returns the same result for the same input and has no observable side effects)&lt;br /&gt;
(!It must always be recursive)&lt;br /&gt;
(!It must modify at least one variable)&lt;br /&gt;
(!It can only return numbers)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;What does immutability mean in functional programming?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(Existing values are not changed after creation)&lt;br /&gt;
(!Every variable must be global)&lt;br /&gt;
(!Data can never be stored in a list)&lt;br /&gt;
(!Programs cannot create new values)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;What makes a function higher-order?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(It accepts a function as input or returns a function)&lt;br /&gt;
(!It contains more than one loop)&lt;br /&gt;
(!It always runs faster than other functions)&lt;br /&gt;
(!It can only process mathematical formulas)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;What is the main purpose of map?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(To apply a function to every element of a collection)&lt;br /&gt;
(!To remove all duplicate elements)&lt;br /&gt;
(!To sort a collection into alphabetical order)&lt;br /&gt;
(!To store values in mutable variables)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;What does filter do?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(It keeps elements that satisfy a predicate)&lt;br /&gt;
(!It transforms every element into a number)&lt;br /&gt;
(!It combines all elements into one result)&lt;br /&gt;
(!It reverses a collection)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;What is a fold used for?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(To combine a structure into an accumulated result)&lt;br /&gt;
(!To create side effects automatically)&lt;br /&gt;
(!To rename all functions in a program)&lt;br /&gt;
(!To delay every computation forever)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;What must a well-designed recursive function include?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(A base case that stops the recursion)&lt;br /&gt;
(!A global variable that changes each time)&lt;br /&gt;
(!An infinite loop)&lt;br /&gt;
(!A file input operation)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;What is function composition?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(Combining functions so one function processes the output of another)&lt;br /&gt;
(!Changing a function into a variable)&lt;br /&gt;
(!Running unrelated functions at random)&lt;br /&gt;
(!Copying the same function many times)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;What is lazy evaluation?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(Delaying evaluation until a result is needed)&lt;br /&gt;
(!Evaluating every possible expression immediately)&lt;br /&gt;
(!Preventing functions from returning results)&lt;br /&gt;
(!Replacing all recursion with loops)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Why can pure functions be easier to test?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(Their results depend only on their explicit inputs)&lt;br /&gt;
(!They never require any input values)&lt;br /&gt;
(!They automatically generate test cases)&lt;br /&gt;
(!They always contain fewer lines of code)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== Memory Game ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;memo-quiz&amp;quot;&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| Pure function || Produces the same output for the same input without observable side effects&lt;br /&gt;
|-&lt;br /&gt;
| Immutability || Keeps an existing value unchanged after creation&lt;br /&gt;
|-&lt;br /&gt;
| Higher-order function || Accepts or returns another function&lt;br /&gt;
|-&lt;br /&gt;
| Recursion || Solves a problem through self-calls on smaller cases&lt;br /&gt;
|-&lt;br /&gt;
| Composition || Connects functions so one output becomes another input&lt;br /&gt;
|-&lt;br /&gt;
| Thunk || Represents a computation that can be evaluated later&lt;br /&gt;
|}&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== Drag and Drop ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;lueckentext-quiz&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Match the correct terms.&lt;br /&gt;
! Topic&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;Applies one transformation to each item&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| Map&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;Keeps items that satisfy a condition&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| Filter&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;Combines items into an accumulated result&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| Fold&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;Stops a recursive definition&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| Base case&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;Delays a computation until needed&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| Lazy evaluation&lt;br /&gt;
|}&lt;br /&gt;
{{E}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== Crossword Puzzle ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;kreuzwort-quiz&amp;quot;&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| Purity || Which property means that a function has no observable side effects and is deterministic for the same input?&lt;br /&gt;
|-&lt;br /&gt;
| Immutable || What adjective describes a value that is not changed after it is created?&lt;br /&gt;
|-&lt;br /&gt;
| Recursion || What technique lets a function call itself on a smaller case?&lt;br /&gt;
|-&lt;br /&gt;
| Lambda || What word names an anonymous function notation and a foundational calculus?&lt;br /&gt;
|-&lt;br /&gt;
| Composition || What technique links functions so that one output becomes another input?&lt;br /&gt;
|-&lt;br /&gt;
| Predicate || What kind of function returns a Boolean result used by filter?&lt;br /&gt;
|}&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== LearningApps ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;iframe&amp;gt; https://learningapps.org/index.php?s=Functional+Programming+Concepts &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== Cloze Text ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;quiz display=simple&amp;gt;&lt;br /&gt;
{&amp;#039;&amp;#039;&amp;#039;Complete the text.&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
|type=&amp;quot;{}&amp;quot;}&lt;br /&gt;
A { pure function } produces the same result for the same explicit input and avoids observable side effects. With { immutability }, existing values are not modified after they are created. A { higher-order function } can accept another function as an argument or return one as a result. The operation { map } applies a transformation to every element of a collection. The operation { filter } keeps elements that satisfy a predicate. A { fold } combines elements into an accumulated result. A recursive definition needs a { base case } so that evaluation can stop. With { lazy evaluation }, an expression may be delayed until its value is required.&lt;br /&gt;
&amp;lt;/quiz&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Open-Ended Tasks =&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
=== Easy ===&lt;br /&gt;
# [[English:Pure Function Test|Pure Function Test]]: Write two small functions, one pure and one impure, and explain which observable behavior makes them different.&lt;br /&gt;
# [[English:Map a Dataset|Map a Dataset]]: Choose a short list of numbers and use a map operation to transform every element; show both the input and output.&lt;br /&gt;
# [[English:Predicate Design|Predicate Design]]: Create three predicates for a list of integers and explain what each predicate would keep when used with filter.&lt;br /&gt;
# [[English:Functional Vocabulary Poster|Functional Vocabulary Poster]]: Produce a one-page visual poster that explains purity, immutability, higher-order functions, recursion, and composition with your own examples.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
=== Standard ===&lt;br /&gt;
# [[English:Recursive List Processing|Recursive List Processing]]: Implement a recursive function that calculates the length or sum of a list, identify its base case, and trace the first four calls.&lt;br /&gt;
# [[English:Pipeline Challenge|Pipeline Challenge]]: Build a data-processing pipeline using map, filter, and fold, then explain the role of each stage in clear English.&lt;br /&gt;
# [[English:Paradigm Interview|Paradigm Interview]]: Interview a programmer, teacher, or advanced student about when functional programming ideas are useful, then compare the interview with concepts from this course.&lt;br /&gt;
# [[English:Functional Video Explanation|Functional Video Explanation]]: Create a two-minute teaching video that demonstrates function composition with at least three small functions and one complete input-to-output trace.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
=== Advanced ===&lt;br /&gt;
# [[English:Imperative to Functional Refactoring|Imperative to Functional Refactoring]]: Take a short loop-based program and refactor it toward a functional style, then compare readability, state changes, and testability.&lt;br /&gt;
# [[English:Lazy Evaluation Experiment|Lazy Evaluation Experiment]]: Use a language or environment that supports lazy or generator-style evaluation, observe when values are produced, and document what changes when only part of a sequence is requested.&lt;br /&gt;
# [[English:Lambda Calculus Model|Lambda Calculus Model]]: Represent two simple functions as lambda expressions, demonstrate function application step by step, and connect the notation to a real programming-language example.&lt;br /&gt;
# [[English:Functional Architecture Project|Functional Architecture Project]]: Design a small application that separates pure domain logic from input and output effects, implement a prototype, and justify where you placed each effectful boundary.&lt;br /&gt;
&lt;br /&gt;
{{:Open Task - Create a MOOC}}&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Learning Assessment =&lt;br /&gt;
&lt;br /&gt;
# [[English:Reasoning About Purity|Reasoning About Purity]]: Given three short program fragments, classify each as pure or impure and justify your decision using determinism and side effects.&lt;br /&gt;
# [[English:Transformation Design|Transformation Design]]: Solve a collection-processing problem with map, filter, and fold, then explain why the chosen order of operations is correct.&lt;br /&gt;
# [[English:Recursion Analysis|Recursion Analysis]]: Trace a recursive function, identify its base and recursive cases, and explain whether every valid input moves toward termination.&lt;br /&gt;
# [[English:Composition Transfer|Composition Transfer]]: Decompose a new real-world data transformation into small functions and show how they can be composed into a pipeline.&lt;br /&gt;
# [[English:Paradigm Comparison|Paradigm Comparison]]: Compare functional and imperative solutions to the same problem using criteria such as state management, testability, readability, and concurrency.&lt;br /&gt;
# [[English:Effect Boundary Design|Effect Boundary Design]]: Propose an architecture for a small interactive program and explain which parts should remain pure and which parts must perform side effects.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Evidence of Learning =&lt;br /&gt;
&lt;br /&gt;
Strong evidence of learning includes both knowledge and practical performance. You should be able to explain the meaning of purity, referential transparency, immutability, first-class functions, higher-order functions, map, filter, fold, recursion, composition, lambda expressions, pattern matching, lazy evaluation, and controlled side effects.&lt;br /&gt;
&lt;br /&gt;
You should also be able to:&lt;br /&gt;
# [[English:Code Reading|Code Reading]]: Predict the result of short functional expressions and trace recursive evaluation.&lt;br /&gt;
# [[English:Program Construction|Program Construction]]: Write small pure functions and combine them into larger transformations.&lt;br /&gt;
# [[English:Program Analysis|Program Analysis]]: Identify hidden state changes, side effects, base cases, predicates, and data-flow stages.&lt;br /&gt;
# [[English:Refactoring|Refactoring]]: Transform a suitable imperative solution into a more functional form without changing its intended result.&lt;br /&gt;
# [[English:Testing Strategy|Testing Strategy]]: Design tests that take advantage of deterministic pure functions.&lt;br /&gt;
# [[English:Transfer|Transfer]]: Recognize functional ideas when they appear in a language that is not primarily functional.&lt;br /&gt;
# [[English:Communication|Communication]]: Explain design choices using accurate computer-science vocabulary and clear examples.&lt;br /&gt;
# [[English:Product Evidence|Product Evidence]]: Present code, diagrams, traces, reflections, or a working prototype that demonstrates the concepts in context.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= OERs on the Topic =&lt;br /&gt;
&lt;br /&gt;
The English Wikipedia article on functional programming provides a broad open reference that you can use to review terminology, history, language examples, and related concepts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;iframe&amp;gt; https://en.m.wikipedia.org/wiki/Functional_programming &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Linked Learning Areas =&lt;br /&gt;
&lt;br /&gt;
{| align=center&lt;br /&gt;
{{:D-Tab}}&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;[[English:Functional Programming Concepts|Functional Programming Concepts]]&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
# [[English:Pure function|Pure function]]&lt;br /&gt;
# [[English:Referential transparency|Referential transparency]]&lt;br /&gt;
# [[English:Immutable object|Immutable object]]&lt;br /&gt;
# [[English:Higher-order function|Higher-order function]]&lt;br /&gt;
# [[English:Lambda calculus|Lambda calculus]]&lt;br /&gt;
# [[English:Recursion|Recursion]]&lt;br /&gt;
# [[English:Function composition|Function composition]]&lt;br /&gt;
# [[English:Pattern matching|Pattern matching]]&lt;br /&gt;
# [[English:Lazy evaluation|Lazy evaluation]]&lt;br /&gt;
# [[English:Type system|Type system]]&lt;br /&gt;
# [[English:Programming paradigm|Programming paradigm]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Functional programming connects computer science with mathematical reasoning, software engineering, data processing, concurrency, and the study of programming-language design. It is especially useful for learning how abstraction can reduce complexity and how careful control of state can improve reliability.&lt;br /&gt;
&lt;br /&gt;
[[Category:English]]&lt;br /&gt;
[[Category:Computer Science]]&lt;br /&gt;
[[Category:Programming]]&lt;br /&gt;
[[Category:Software Engineering]]&lt;br /&gt;
[[Category:Programming Paradigms]]&lt;br /&gt;
[[Category:Grades 11-13]]&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= aiMOOC Projects =&lt;br /&gt;
[[Category:English]]&lt;br /&gt;
[[Category:Functional Programming Concepts]]&lt;br /&gt;
[[Category:Computer Science]]&lt;br /&gt;
[[Category:Programming]]&lt;br /&gt;
[[Category:Software Engineering]]&lt;br /&gt;
[[Category:Grades 11-13]]&lt;br /&gt;
[[Category:AI_MOOC]]&lt;br /&gt;
[[Category:GPT aiMOOC]]&lt;br /&gt;
{{MT}}&lt;/div&gt;</summary>
		<author><name>Glanz</name></author>
	</entry>
</feed>