-
First-Class Object and High-Order functionDynamicPL/Python 2019. 11. 2. 14:02
1. Overview
In programming language design, a first-class citizen (also type, object, entity, or value) in a given programming language is an entity that supports all the operations generally available to other entities. These operations typically include being passed as an argument, returned from a function, modified, and assigned to a variable.
In mathematics and computer science, a higher-order function is a function that does at least one of the following:
- takes one or more functions as arguments (i.e. procedural parameters),
- returns a function as its result.
All other functions are first-order functions. In mathematics, higher-order functions are also termed operators or functionals. The differential-operator in calculus is a common example, since it maps a function to its derivative, also a function. Higher-order functions should not be confused with other uses of the word "functor" throughout mathematics, see Functor (disambiguation).
In the untyped lambda calculus, all functions are higher-order; in a typed lambda calculus, from which most functional programming languages are derived, higher-order functions that take one function as argument are values with types of the form $(\tau _{1}\to \tau _{2})\to\tau _{3}$
2. Description
2.1 First-Class Object
It can be passed to a function as an argument
It can be returned from a function
It can be assigned to a variable
It can be stored in a data structure such as a list, tuple, dictionary, etc.
Functions are also first-class objects
2.2 High-Order Function
It takes a function as an argument and/or return a function
3. Examples
4. Reference
'DynamicPL > Python' 카테고리의 다른 글
Decorators (0) 2019.11.07 Closure (0) 2019.11.07 Slice (0) 2019.10.28 Sequence (0) 2019.10.26 List, Dictionary, Set Comprehensions, and Difference between List Comprehensions and Generator expressions (0) 2019.10.22