词条 | Tacit programming |
释义 |
UNIX scripting uses the paradigm with pipes. For example, a sequence of operations in an applicative language such as the following Python code: ... is written in point-free style as the composition of a sequence of functions, without parameters:[3] The key idea in tacit programming is to assist in operating at the appropriate level of abstraction. That is, to translate the natural transformation given by currying into computer functions, where the left represents the uncurried form of a function and the right the curried. CA denotes the functionals from A to C (see also exponential object), while A × B denotes the Cartesian product of A and B. ExamplesFunctional programmingA simple example (in Haskell) is a program which takes a sum of a list. A programmer might define a sum recursively using a pointed (cf. value-level programming) method as: However, by noting this as a fold the programmer could replace this with: And then the argument is not needed, so this can be replaced with which is point-free. Another example uses the dot operator: The following Haskell-like pseudo-code exposes how to reduce a function definition to its point-free equivalent: so Finally, to see a complex example imagine a map filter program which takes a list, applies a function to it, and then filters the elements based on a criterion It can be expressed point-free[4] as Note that, as stated previously, the points in 'point-free' refer to the arguments, not to the use of dots; a common misconception.[5]APL familyIn J, the same sort of point-free code occurs in a function made to compute the average of a list (array) of numbers:
Euler's formula expressed tacitly: ( Stack-basedIn stack-oriented programming languages (and concatenative ones, most of which are stack based), point-free methods are commonly used. For example, a procedure to compute the Fibonacci numbers might look like the following in PostScript: UNIX pipeline{{main|Pipeline (Unix)}}In UNIX scripting the functions are computer programs which receive data from standard input and send the results to standard output. For example, is a tacit or point-free composition which returns the counts of its arguments and the arguments, in the order of decreasing counts. The 'sort' and 'uniq' are the functions, the '-c' and '-rn' control the functions, but the arguments are not mentioned. The '|' is the composition operator. See also
References1. ^1 Manuel Alcino Cunha (2005) Point-free Program Calculation 2. ^W. Neville Holmes, ed. (2006) Computers and People 3. ^{{cite web | url=http://concatenative.org/wiki/view/Concatenative%20language/Name%20code%20not%20values | title=Name code not values | publisher=Concatenative.org | accessdate=13 September 2013}} 4. ^pipermail 5. ^{{Cite web|url=https://wiki.haskell.org/Pointfree#But_pointfree_has_more_points.21|title=Pointfree - HaskellWiki|website=wiki.haskell.org|access-date=2016-06-05}} External links
1 : Programming paradigms |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。