Talk:Currying
From Wikipedia, the free encyclopedia
- To do: How about a practical example for currying helping to formulate clearer code? "What is it good for?" --84.114.179.138 17:30, 13 May 2006 (UTC)
- To Do: Good idea. It is very useful for list manipulation. I may slice off my C# example and give a real application ((('a * 'b) -> 'b) -> 'b -> 'a list -> 'b function applied to lists), but I'm not sure how much space it would deserve.
- To Do: Link to the article about Foldr (and by extension foldl) perhaps? It is very common that you have a list of things that you want to turn into one big thing before outputting it. Here the functions foldr and foldl (Haskell and ML names) come in very handy for example in ML you can do
val sumList = foldr op+ 0
to get a function sumList that takes a list of integers and returns the sum of its elements. In other words, currying for the sake of currying is not very useful (though it may have some theoretical niceties such as it being possible to consider all functions as unary). You could even argue that all it does is save you a couple of parentheses.
- To do: Add Scheme language definition for currying to any given depth.
(moved from the article -- Timwi 22:20 19 Jun 2003 (UTC))
- To do: Add note that C++ is evolving the ability to curry functions via template libraries such as the Boost Libraries.
[edit] Schönfinkelisation
Who calls currying Schönfinkelisation? I see the link, but it is rather unhelpfdiaul, unless I want to buy the book. Google has three hits for Schönfinkelisation, two of which are this page, and one of which is a PDF in French that claims it is called Schönfinkelisation in Europe. I've spent some time in the UK, and they call it currying there. Is it just called Schönfinkelisation in France? Jm307 17:09, 22 August 2006 (UTC)
- Not on the French Wikipédia; they only have Curryfication. I never heard the term "Schönfinkelisation" on any continent. It may be that that term has some currency among logicians, while "Currying" is for programmers. --LambiamTalk 18:25, 22 August 2006 (UTC)
-
- I forgot about this! So, is this just one of those "we'll take it on faith" things? Jm307 20:55, 15 November 2006 (UTC)
[edit] Is the c++ example bogus?
I think the c++ example is bogus. It is true that plus_one(2) does get you 3, but you can't pass plus_one to functions that take a function pointer as an argument. In other words, it's not a real function; it just looks like one when you call it in certain ways. Maw 00:12, 3 August 2006 (UTC)
- Define "function pointer". C++ is notable in that it can do everything - it can have real functions, with a statically defined pointer, that can be pointed to by C code and template-free C++ code, and it can have abstract functor objects to which any sort of computability-theoric transformation can be applied. By fully applying all the abstractions provided by the standard library alone (not counting the countless others provided by libraries like Boost), C++ can turn into another language altogether.
It's not real currying - agreed. It's just a class that takes an integer parameter in its constructor and has another function to add that integer to an extra parameter.. Dastle 05:03, 14 October 2006 (UTC)
- If it's bogus we should not keep it. Therefore I've removed it. In general, let us agree that a language supports currying if in that language you can define some higher-order operation CURRY that, applied to some f : (X × Y) → Z, produces CURRY(f) : X → (Y → Z). The fact that in language FOO you can define both f : (X × Y) → Z and g : X → (Y → Z) does not already mean FOO supports currying. --LambiamTalk 13:06, 12 November 2006 (UTC)
[edit] Why the Perl6 example was suppressed?
Spayrard 23:35, 18 September 2006 (UTC)