FENE: Difference between revisions
en>Sergius-eu |
en>Niceguyedc |
||
Line 1: | Line 1: | ||
{{Wiktionary|apply}} | |||
In [[mathematics]] and [[computer science]], '''Apply''' is a function that applies functions to arguments. It is central to [[programming language]]s derived from [[lambda calculus]], such as [[LISP]] and [[Scheme (programming language)|Scheme]], and also in [[functional language]]s. In particular, it has a role in the study of the [[denotational semantics]] of computer programs, because it is a [[Scott continuity|continuous function]] on [[complete partial order]]s. | |||
In [[category theory]], '''Apply''' is important in [[Cartesian closed categories]], (and thus, also in [[Topos theory]]), where it is a [[universal morphism]], [[right adjoint]] to [[currying]]. | |||
==Programming== | |||
In computer programming, '''apply''' applies a function to a list of arguments. ''[[Eval]]'' and ''apply'' are the two interdependent components of the ''[[eval-apply cycle]]'', which is the essence of evaluating Lisp, described in [[Structure and Interpretation of Computer Programs|SICP]].<ref>Harold Abelson, Gerald Jay Sussman, Julie Sussman, ''Structure and Interpretation of Computer Programs'', (1996) MIT Press, ISBN 0-262-01153-0. ''See [http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-26.html Section 4.1, The Metacircular Evaluator]''</ref> | |||
===Apply function=== | |||
Apply is also the name of a special function in many languages, which takes a function and a list, and uses the list as the function's own argument list, as if the function were called with the elements of the list as the arguments. This is important in languages with [[variadic function]]s, because this is the only way to call a function with an indeterminate (at compile time) number of arguments. | |||
====Common Lisp and Scheme==== | |||
In [[Common Lisp]] '''apply''' is a function that applies a function to a list of arguments (note here that "+" is a variadic function that takes any number of arguments):<source lang="lisp">(apply #'+ (list 1 2))</source> | |||
Similarly in Scheme:<source lang="scheme">(apply + (list 1 2))</source> | |||
====C++==== | |||
In [[C++]], Bind <ref>http://www.boost.org/doc/libs/1_49_0/libs/bind/bind.html#with_functions</ref> is used either via the std namespace or via the boost namespace. | |||
====C# and Java==== | |||
In [[C Sharp (programming language)|C#]] and [[Java (programming language)|Java]], variadic arguments are simply collected in an array. Caller can explicitly pass in an array in place of the variadic arguments. This can only be done for a variadic parameter. It is not possible to apply an array of arguments to non-variadic parameter without using [[reflection (computer science)|reflection]]. An ambiguous case arises should the caller want to pass an array itself as one of the arguments rather than using the array as a ''list'' of arguments. In this case, the caller should cast the array to <code>Object</code> to prevent the compiler from using the ''apply'' interpretation.<source lang="java">variadicFunc(arrayOfArgs);</source> | |||
====Go==== | |||
In [[Go (programming language)|Go]], typed variadic arguments are simply collected in a slice. The caller can explicitly pass in a slice in place of the variadic arguments, by appending a <code>...</code> to the slice argument. This can only be done for a variadic parameter. The caller can not apply an array of arguments to non-variadic parameters, without using reflection..<pre>s := []string{"foo", "bar"} | |||
variadicFunc(s...)</pre> | |||
====Haskell==== | |||
In [[Haskell (programming language)|Haskell]], functions may be applied by simple juxtaposition: | |||
<source lang="haskell"> | |||
func param1 param2 ... | |||
</source> | |||
In Haskell, the syntax may also be interpreted that each parameter curries its function in turn. In the above example, "func param1" returns another function accepting one fewer parameters, that is then applied to param2, and so on, until the function has no more parameters. | |||
====JavaScript==== | |||
In [[JavaScript]], function objects have an <code>apply</code> method, the first argument is the value of the <code>this</code> keyword inside the function; the second is the list of arguments:<source lang="javascript">func.apply(null, args);</source> | |||
====Lua==== | |||
In [[Lua (programming language)|Lua]], apply can be written this way: <source lang="lua">function apply(f,l) | |||
return f(unpack(l)) | |||
end </source> | |||
====Perl==== | |||
In [[Perl]], arrays, hashes and expressions are automatically "flattened" into a single list when evaluated in a list context, such as in the argument list of a function:<source lang="perl"> | |||
# Equivalent subroutine calls: | |||
@args = (@some_args, @more_args); | |||
func(@args); | |||
func(@some_args, @more_args); | |||
</source> | |||
====PHP==== | |||
In [[PHP]], <code>apply</code> is called <code>call_user_func_array</code>:<source lang="php">call_user_func_array('func_name', $args);</source> | |||
====Python and Ruby==== | |||
In [[Python (programming language)|Python]] and [[Ruby (programming language)|Ruby]], the same asterisk notation used in defining [[variadic function]]s is used for calling a function on a sequence and array respectively:<source lang="python">func(*args)</source> | |||
Python originally had an apply function, but this was [[deprecated]] in favour of the asterisk in 2.3 and removed in 3.0.<ref>{{cite web | title = Non-essential built-in functions | work = Python Library Reference | date = 8 February 2005 | url = http://docs.python.org/release/2.3.5/lib/non-essential-built-in-funcs.html | accessdate = 19 May 2013}}</ref> | |||
====R==== | |||
In [[R (programming language)|R]], <code lang="rsplus">do.call</code> constructs and executes a function call from a name or a function and a list of arguments to be passed to it:<source lang="rsplus"> | |||
f(x1, x2) | |||
# can also be performed via | |||
do.call(what = f, args = list(x1, x2)) | |||
</source> | |||
====Smalltalk==== | |||
In [[Smalltalk]], block (function) objects have a <code>valueWithArguments:</code> method which takes an array of arguments: <source lang="smalltalk">aBlock valueWithArguments: args</source> | |||
==Universal property== | |||
Consider a [[Function (mathematics)|function]] <math>g:(X\times Y)\to Z</math>, that is, <math>g\isin [(X\times Y)\to Z]</math> where the bracket notation <math>[A\to B]</math> denotes the [[space of functions]] from ''A'' to ''B''. By means of [[currying]], there is a unique function <math>\mbox{curry}(g) :X\to [Y\to Z]</math> | |||
<!-- something like this is needed, because not everybody knows what does currying means: , where <math>curry (f)\stackrel{def}{=}\lambda x.(\lambda y.(g(x,y))</math> with type <math>curry:((\alpha\times\beta)\to\gamma)\to(\alpha\to(\beta\to\gamma))</math> here <math>\lambda</math> is the abstractor of the <math>\lambda</math>-calculus | |||
The lambda may be confuse the reader not familiar with lambda calculus and its use in category theory as told below -->. | |||
Then '''Apply''' provides the [[universal morphism]] | |||
:<math>\mbox{Apply}:([Y\to Z]\times Y) \to Z</math>, | |||
so that | |||
:<math>\mbox {Apply}(f,y)=f(y)</math> | |||
or, equivalently one has the [[commuting diagram]] | |||
<!-- it is not clear what does this mean. can a pair of functions be applied to an object?, this needs an explanation --> | |||
:<math>\mbox{Apply} \circ \left( \mbox{curry}(g) \times \mbox{id}_Y \right) = g</math> | |||
<!-- Maybe something like this can improve reading | |||
:<math>f(x)=g(f,x)</math> | |||
:<math>= (\mbox{Apply} \circ (\mbox{curry}(g),\mbox{id}_Y))(f,x)</math> | |||
:<math>= (\mbox{Apply} ((\mbox{curry}(g),\mbox{id}_Y ))(f,x))</math> | |||
:<math>= (\mbox{Apply} ((\mbox{curry}(g))(f),\mbox{id}_Y x)) | |||
</math> | |||
--> | |||
The notation <math>[A\to B]</math> for the space of functions from ''A'' to ''B'' occurs more commonly in computer science. In [[category theory]], however, <math>[A\to B]</math> is known as the [[exponential object]], and is written as <math>B^A</math>. There are other common notational differences as well; for example ''Apply'' is often called ''Eval'',<ref>Saunders Mac Lane, ''Category Theory''</ref> even though in computer science, these are not the same thing, with [[eval]] distinguished from ''Apply'', as being the evaluation of the quoted string form of a function with its arguments, rather than the application of a function to some arguments. | |||
Also, in category theory, ''curry'' is commonly denoted by <math>\lambda</math>, so that <math>\lambda g</math> is written for ''curry''(''g''). This notation is in conflict with the use of <math>\lambda</math> in [[lambda calculus]], where lambda is used to denote free variables. With all of these notational changes accounted for, the adjointness of ''Apply'' and ''curry'' is then expressed in the commuting diagram | |||
[[Image:ExponentialObject-01.png|center|Universal property of the exponential object]] | |||
The articles on [[exponential object]] and [[Cartesian closed category]] provide a more precise discussion of the category-theoretic formulation of this idea. Thus use of lambda here is not accidental; Cartesian-closed categories provide the general, natural setting for lambda calculus. | |||
==Topological properties== | |||
In [[order theory]], in the category of [[complete partial order]]s endowed with the [[Scott topology]], both ''curry'' and ''apply'' are [[continuous function]]s (that is, they are [[Scott continuous]]).<ref>H.P. Barendregt, ''The Lambda Calculus'', (1984) North-Holland ISBN 0-444-87508-5</ref> This property helps establish the foundational validity of the study of the [[denotational semantics]] of computer programs. | |||
==References== | |||
<references/> | |||
[[Category:Adjoint functors]] | |||
[[Category:Lambda calculus]] | |||
[[Category:Functional programming]] |
Revision as of 07:44, 12 June 2013
Property Brokers and Team Managers – Looking for good Actual Estate Agency to join or contemplating which is the Finest Property Agency to join in Singapore? Join Leon Low in OrangeTee Singapore! In OrangeTee, we've much more attractive commission structure than before, enrichment courses, 10 most vital components to hitch OrangeTee and 1 motive to join Leon Low and his Workforce. 1. Conducive working environment
Via PropNex International, we continually construct on our fame in the international property enviornment. Click here for more of our abroad initiatives. Instances have modified. We don't see those unlawful hawkers anymore. Instead, nicely dressed property brokers were seen reaching out to people visiting the market in the morning. Real estate can be a lonely enterprise and it is straightforward to really feel demoralised, especially when there are no enquiries despite your greatest effort in advertising your shopper's property. That is the place having the fitting assist from fellow associates is essential. Our firm offers administration services for condominiums and apartments. With a crew of qualified folks, we assist to make your estate a nicer place to stay in. HDB Flat for Hire 2 Rooms
Achievers are all the time the first to check new technologies & providers that can help them enhance their sales. When property guru first began, many brokers didn't consider in it until they began listening to other colleagues getting unbelievable outcomes. Most brokers needs to see proof first, before they dare to take the first step in attempting. These are often the late comers or late adopters. There is a purpose why top achievers are heading the wave or heading the best way. Just because they try new properties in singapore issues ahead of others. The rest just observe after!
Firstly, a Fraudulent Misrepresentation is one that is made knowingly by the Representor that it was false or if it was made without belief in its fact or made recklessly without concerning whether or not it is true or false. For instance estate agent A told the potential consumers that the tenure of a landed property they are considering is freehold when it is really one with a ninety nine-yr leasehold! A is responsible of constructing a fraudulent misrepresentation if he is aware of that the tenure is the truth is a ninety nine-yr leasehold instead of it being freehold or he didn't consider that the tenure of the house was freehold or he had made the assertion with out caring whether or not the tenure of the topic property is in fact freehold.
I such as you to be, am a brand new projects specialist. You've got the conception that new tasks personnel should be showflat certain. Should you're eager, let me train you the right way to master the entire show flats island vast as a substitute of getting to stay just at 1 place. Is that attainable you may ask, well, I've achieved it in 6 months, you can too. Which company is well-recognized and is actually dedicated for developing rookie within the industry in venture sales market with success? Can a rookie join the company's core group from day one? I wish to propose a third class, which I have been grooming my agents in the direction of, and that is as a Huttons agent, you will be able to market and have knowledge of ALL Huttons projects, and if essential, projects exterior of Huttons as properly.
GPS has assembled a high workforce of personnel who are additionally well-known figures in the native actual property scene to pioneer this up-and-coming organization. At GPS Alliance, WE LEAD THE WAY! Many people have asked me how I managed to earn S$114,000 from my sales job (my third job) at age 24. The reply is easy. After graduation from NUS with a Historical past diploma, my first job was in actual estate. Within the ultimate part of this series, I interview one of the top agents in ERA Horizon Group and share with you the secrets to his success! Learn it RIGHT HERE
Notice that the application must be submitted by the appointed Key Government Officer (KEO) such as the CEO, COO, or MD. Once the KEO has submitted the mandatory paperwork and assuming all documents are in order, an email notification shall be sent stating that the applying is permitted. No hardcopy of the license might be issued. A delicate-copy could be downloaded and printed by logging into the CEA website. It takes roughly four-6 weeks to course of an utility.
In mathematics and computer science, Apply is a function that applies functions to arguments. It is central to programming languages derived from lambda calculus, such as LISP and Scheme, and also in functional languages. In particular, it has a role in the study of the denotational semantics of computer programs, because it is a continuous function on complete partial orders.
In category theory, Apply is important in Cartesian closed categories, (and thus, also in Topos theory), where it is a universal morphism, right adjoint to currying.
Programming
In computer programming, apply applies a function to a list of arguments. Eval and apply are the two interdependent components of the eval-apply cycle, which is the essence of evaluating Lisp, described in SICP.[1]
Apply function
Apply is also the name of a special function in many languages, which takes a function and a list, and uses the list as the function's own argument list, as if the function were called with the elements of the list as the arguments. This is important in languages with variadic functions, because this is the only way to call a function with an indeterminate (at compile time) number of arguments.
Common Lisp and Scheme
In Common Lisp apply is a function that applies a function to a list of arguments (note here that "+" is a variadic function that takes any number of arguments):
(apply #'+ (list 1 2))
Similarly in Scheme:
(apply + (list 1 2))
C++
In C++, Bind [2] is used either via the std namespace or via the boost namespace.
C# and Java
In C# and Java, variadic arguments are simply collected in an array. Caller can explicitly pass in an array in place of the variadic arguments. This can only be done for a variadic parameter. It is not possible to apply an array of arguments to non-variadic parameter without using reflection. An ambiguous case arises should the caller want to pass an array itself as one of the arguments rather than using the array as a list of arguments. In this case, the caller should cast the array to Object
to prevent the compiler from using the apply interpretation.
variadicFunc(arrayOfArgs);
Go
In Go, typed variadic arguments are simply collected in a slice. The caller can explicitly pass in a slice in place of the variadic arguments, by appending a ...
to the slice argument. This can only be done for a variadic parameter. The caller can not apply an array of arguments to non-variadic parameters, without using reflection..
s := []string{"foo", "bar"} variadicFunc(s...)
Haskell
In Haskell, functions may be applied by simple juxtaposition:
func param1 param2 ...
In Haskell, the syntax may also be interpreted that each parameter curries its function in turn. In the above example, "func param1" returns another function accepting one fewer parameters, that is then applied to param2, and so on, until the function has no more parameters.
JavaScript
In JavaScript, function objects have an apply
method, the first argument is the value of the this
keyword inside the function; the second is the list of arguments:
func.apply(null, args);
Lua
In Lua, apply can be written this way:
function apply(f,l)
return f(unpack(l))
end
Perl
In Perl, arrays, hashes and expressions are automatically "flattened" into a single list when evaluated in a list context, such as in the argument list of a function:
# Equivalent subroutine calls:
@args = (@some_args, @more_args);
func(@args);
func(@some_args, @more_args);
PHP
In PHP, apply
is called call_user_func_array
:
call_user_func_array('func_name', $args);
Python and Ruby
In Python and Ruby, the same asterisk notation used in defining variadic functions is used for calling a function on a sequence and array respectively:
func(*args)
Python originally had an apply function, but this was deprecated in favour of the asterisk in 2.3 and removed in 3.0.[3]
R
In R, do.call
constructs and executes a function call from a name or a function and a list of arguments to be passed to it:
f(x1, x2)
# can also be performed via
do.call(what = f, args = list(x1, x2))
Smalltalk
In Smalltalk, block (function) objects have a valueWithArguments:
method which takes an array of arguments:
aBlock valueWithArguments: args
Universal property
Consider a function , that is, where the bracket notation denotes the space of functions from A to B. By means of currying, there is a unique function . Then Apply provides the universal morphism
so that
or, equivalently one has the commuting diagram
The notation for the space of functions from A to B occurs more commonly in computer science. In category theory, however, is known as the exponential object, and is written as . There are other common notational differences as well; for example Apply is often called Eval,[4] even though in computer science, these are not the same thing, with eval distinguished from Apply, as being the evaluation of the quoted string form of a function with its arguments, rather than the application of a function to some arguments.
Also, in category theory, curry is commonly denoted by , so that is written for curry(g). This notation is in conflict with the use of in lambda calculus, where lambda is used to denote free variables. With all of these notational changes accounted for, the adjointness of Apply and curry is then expressed in the commuting diagram
The articles on exponential object and Cartesian closed category provide a more precise discussion of the category-theoretic formulation of this idea. Thus use of lambda here is not accidental; Cartesian-closed categories provide the general, natural setting for lambda calculus.
Topological properties
In order theory, in the category of complete partial orders endowed with the Scott topology, both curry and apply are continuous functions (that is, they are Scott continuous).[5] This property helps establish the foundational validity of the study of the denotational semantics of computer programs.
References
- ↑ Harold Abelson, Gerald Jay Sussman, Julie Sussman, Structure and Interpretation of Computer Programs, (1996) MIT Press, ISBN 0-262-01153-0. See Section 4.1, The Metacircular Evaluator
- ↑ http://www.boost.org/doc/libs/1_49_0/libs/bind/bind.html#with_functions
- ↑ Template:Cite web
- ↑ Saunders Mac Lane, Category Theory
- ↑ H.P. Barendregt, The Lambda Calculus, (1984) North-Holland ISBN 0-444-87508-5