A function is called a higher-order function if its arguments and values are allowed to be functions.
This is an important property that most good programming languages possess.
The composition and tupling operations are examples of functions that take other functions as arguments and return functions as results.
For example, suppose we have two functions f: A → B and g: B → C.
Then we can write g • f in prefix form • (f, g).
Viewed in this way, composition is a higher-order function with the following type expression:
(A → B) × (B → C) → (A → C).
The map function takes one argument, a function f: A → B, and returns as a result the function map(f): Lists[A] → Lists[B], where map(f) applies f to each element in its argument list.
For example, let f: { a, b, c } → { 1, 2, 3 } be defined by f(a) = f(b) = 1 and f(c) = 2.
Then map(f) applied to the list <a, b, c, a> can be calculated as follows:
map(f)(<a, b, c, a>) = <f(a), f(b), f(c), f(a)> = <1, 1, 2, 1>.
.
.
We have map(f: A → B): [A] → [B] or, in curry form map: (A → B) → [A] → [B] which we can see below.
λ :{
| add5 :: Int -> Int
| add5 x = x + 5
| :}
Function `add5 :: Int -> Int` is defined
λ :type map
map :: (a -> b) -> [a] -> [b]
λ :type add5
add5 :: Int -> Int
λ :type map add5
map add5 :: [Int] -> [Int]
λ :type map add5
map add5 :: [Int] -> [Int]
λ :type map add5 [1, 9, 12, 18, 20]
map add5 [1, 9, 12, 18, 20] :: [Int]
λ map add5 [1, 9, 12, 18, 20]
[6,14,17,23,25]From above, we will notice that map function signature is (a -> b) -> [a] -> [b].
It follows the higher-order function definition that "its arguments and values are allowed to be functions". ;-)
These definitions are from this book, Discrete Structure, Logic, and Computability.
ที่มาที่ไปของ gist นี้: https://www.linkedin.com/posts/fresult_maths4workingprogrammers-activity-6997207193452257280-_Pxn
Composition Function Reference: https://www.aplustopper.com/composition-functions-f-o-gx
by the way, just note.
High school's student may have seen Higher-Order Function before...
h is a function that take function g and return function f
More Example: if term



