Sriram on Currying in C# 2.0

Don Box's Spoutlet

Syndication

Fun code found here.  Look for the C# 3.0 version in September :-)

Posted Aug 08 2005, 05:51 AM by don-box

Comments

wolm wrote re: Sriram on Currying in C# 2.0
on 08-08-2005 11:07 PM
Yes, generics certainly leads to clear and understandable code...

Does someone have an example of when "Currying" is useful?
James Alexander's IMessage wrote Continuations
on 08-09-2005 12:06 PM
Is it just me or are people seriously coming up with "common-sense/clear as day" terms and methodologies...
Keith J. Farmer wrote re: Sriram on Currying in C# 2.0
on 08-09-2005 7:51 PM
Wolm:

From Wikipedia: "The practical motivation for currying is that very often the functions you get by supplying some but not all of the arguments to a curried function are useful; for example, many languages have a function or operator similar to plus_one. Currying makes it easy to define these functions."

Lecture notes on currying: http://www.informatics.sussex.ac.uk/courses/funcprog/Handouts/lecture5.pdf

I'll leave it to you to actually look things up, if you're interested. Personally, I'm more gung-ho over LCG.
wolm wrote re: Sriram on Currying in C# 2.0
on 08-09-2005 11:23 PM
Yes -- I read the Wikipedia too, but I didn't find the lecture. Thanks for that.

But still. I'm looking for a useful example beyond "an easy way to define a function for the ++ operator".

Or in other words: How is currying going to help me in my everyday software development?
Sriram Krishnan wrote Winning an Oscar
on 08-10-2005 12:47 PM
Within the span of 2 days, I get linked to by first Don Box and now, Rico Mariani. This has meant that...
Ivan Tikhonov wrote Useful currying
on 01-08-2006 2:48 AM
Currying useful to create anonymous functions without writing lambdas.

imagine that we need to append 2 for each element of list l. In haskell it will be:

let f = \x -> add(x, 2) -- creating lambda
in map(f, l) -- applying it to list

with currying it looks like:

let f = add 2
in map f l

Evaluation of (add 2) returns function which accepts single argument and sums it with 2.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?