Talk:First-class function: Difference between revisions

Content deleted Content added
Ruud Koot (talk | contribs)
{{todo}}
Line 248:
 
:: This leads me to think that what is classed as first class for functions is language dependant. For example, if you can use strings and integers as keys to hash/dictionary, then maybe for a function to be first class in that language a function must be able to be used in that way too. --[[User:Paddy3118|Paddy]] ([[User talk:Paddy3118|talk]]) 11:34, 13 February 2011 (UTC)
 
==Does Haskell allow functions as keys in a map?==
Or a member of a set for that matter? I'm just thinking what can you do with a string and an integer that you may not be able to do for a function in some languages, and so limit the first-classness of functions.
 
In Python:
<source lang="python">>>> def a(): pass
 
>>> def b(): pass
 
>>> { a:1, b:2}
{<function b at 0x00000000032669C8>: 2, <function a at 0x0000000003266A48>: 1}
>>> { a:1, b:2}[a]
1
>>> {a, b}
{<function a at 0x0000000003266A48>, <function b at 0x00000000032669C8>}
>>> type({a, b})
<class 'set'></source>