|WikiProject Computer science||(Rated Start-class)|
|To-do list for Anonymous function:|
|Sources for development of this article may be located at|
- 1 Lambda in Java
- 2 Typical usage summary?
- 3 Full vs. Some support?
- 4 Expert tag and merge discussion
- 5 Section 3.14 Python
- 6 Ubiquitous in languages with first-class functions... such as Haskell?
- 7 PHP 5!
- 8 Why not use the same example for all languages?
- 9 merge from lambda (programming)
- 10 Advantages?
- 11 Too python centric?
Lambda in Java
Typical usage summary?
The article might be more comprehensible if it introduced anonymous functions as *parameters* to named function. — Preceding unsigned comment added by 22.214.171.124 (talk) 22:11, 21 November 2011 (UTC)
Full vs. Some support?
I wasn't sure what the difference was between "Full" and "Some" support. Added Perl as having "Full" support, since it can do the five examples: sort, map, grep, curry, reduce ('reduce' is in List::Util). And, it has fully anonymous functions. Benizi (talk) 00:16, 20 February 2008 (UTC)
Expert tag and merge discussion
See Talk:First-class_function#Merge_anonymous_function_here. Pcap ping 21:40, 20 August 2009 (UTC)
Section 3.14 Python
Ha! Unexpected humor! Πthon is section 3.14.
Ubiquitous in languages with first-class functions... such as Haskell?
This sentence in the introduction struck me as odd:
- Anonymous functions are convenient to pass as an argument to a higher-order function and are ubiquitous in languages with first-class functions such as Haskell. [emphasis mine]
Why is Haskell used as an example of a language where anonymous functions are convenient–or better yet—why is there an example language at all? Anonymous functions aren't unique to Haskell are there are other more (historically) notable programming languages that use them. —BiT (talk) 02:20, 22 November 2011 (UTC)
Why not use the same example for all languages?
merge from lambda (programming)
Someone put a merge tag on lambda (programming) back in Oct 2011. Discuss this proposal here.
- Yes, merge. Actually, a redicrect may be enough, this page is clearly more complete. linas (talk) 22:15, 8 June 2012 (UTC)
- Merge. Lambda just means "this is an anonymous function" anyway. There's really no reason to have anything besides a line on Lambda (disambiguation) that says that in programming it means anonymous function, and then link to that. Dtm1234 (talk) 21:29, 27 June 2012 (UTC)
The article does not tell me the advantages of this. For example, why is
def divide(x,y): return x/y def divisor(d): return lambda x: divide(x,d) half = divisor(2) third = divisor(3) print half(32), third(32) 16 10 print half(40), third(40) 20 13
any better than the (IMHO) much more obvious and shorter
def divide(x,y): return x/y print divide(32,2), divide(32,3) 16 10 print divide(40,2), divide(40,3) 20 13
Because since you wrote both 40 and 32 two times, you are unnecessarily duplicating data that should be encapsulated. This is obviously not much of a concern in a toy example like that but it starts becoming more pressing when dealing with "complex" structures. Try and review some of your old code with your new knowledge and you'll probably find a lot of examples. — Preceding unsigned comment added by 2A02:1812:908:6100:2E44:FDFF:FE65:9549 (talk) 19:37, 14 April 2014 (UTC)
There are no advantages. As you have noticed, the "plain" form is much more obvious, shorter and, well, plain. As to the answer above, the duplication occurs in both examples and can be avoided by using simple variables. — Preceding unsigned comment added by 126.96.36.199 (talk) 11:33, 5 May 2014 (UTC)
Too python centric?
Why are all of the examples in the Uses section written in Python? Wouldn't this be better suited to a language that puts functions first such as Haskell? — Preceding unsigned comment added by 2A02:1812:908:6100:2E44:FDFF:FE65:9549 (talk) 19:26, 14 April 2014 (UTC)