Click here to Skip to main content
15,921,905 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Creativity: If you can talk about it, you probably can Pin
milo-xml12-Mar-15 2:40
professionalmilo-xml12-Mar-15 2:40 
GeneralRe: Creativity: If you can talk about it, you probably can Pin
Michael Martin12-Mar-15 2:34
professionalMichael Martin12-Mar-15 2:34 
GeneralNaming conventions, FP ain't got none... Pin
Sander Rossel11-Mar-15 9:31
professionalSander Rossel11-Mar-15 9:31 
GeneralRe: Naming conventions, FP ain't got none... Pin
newton.saber11-Mar-15 9:38
newton.saber11-Mar-15 9:38 
GeneralRe: Naming conventions, FP ain't got none... Pin
manchanx11-Mar-15 10:11
professionalmanchanx11-Mar-15 10:11 
GeneralRe: Naming conventions, FP ain't got none... Pin
Sander Rossel11-Mar-15 10:23
professionalSander Rossel11-Mar-15 10:23 
GeneralRe: Naming conventions, FP ain't got none... Pin
harold aptroot11-Mar-15 9:40
harold aptroot11-Mar-15 9:40 
GeneralRe: Naming conventions, FP ain't got none... Pin
Richard Deeming11-Mar-15 10:00
mveRichard Deeming11-Mar-15 10:00 
Nit-picking corner:
Your code example shows partial function application, not currying. They're related, but not quite the same thing. Smile | :)

Currying and partial application is easy* in C#, once you've got your head around the concept:
Currying and Partial Function Application - MSDN Blogs[^]
Currying vs partial function application - Jon Skeet's blog[^]

C#
public static class FunctionalExtensions
{
    public static Func<A, Func<B, R>> Curry<A, B, R>(this Func<A, B, R> f)
    {
        return a => b => f(a, b);
    }
    
    public static Func<B, R> Apply<A, B, R>(this Func<A, B, R> f, A a)
    {
        return b => f(a, b);
    }
}

Func<int, int, int> add = (a, b) => a + b;
// add(5, 5) == 10

Func<int, int> incr = add.Apply(1);
// incr(41) == 42

Func<int, Func<int, int>> curriedAdd = add.Curry();
// curriedAdd(1) == incr

There's a bit more ceremony, as C# isn't as good at inferring argument types as most functional languages, but it's still usable.

* For certain values of "easy".



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: Naming conventions, FP ain't got none... Pin
newton.saber11-Mar-15 10:21
newton.saber11-Mar-15 10:21 
JokeRe: Naming conventions, FP ain't got none... Pin
Richard Deeming11-Mar-15 10:29
mveRichard Deeming11-Mar-15 10:29 
GeneralRe: Naming conventions, FP ain't got none... Pin
Ian Shlasko11-Mar-15 10:40
Ian Shlasko11-Mar-15 10:40 
GeneralRe: Naming conventions, FP ain't got none... Pin
Richard Deeming11-Mar-15 10:43
mveRichard Deeming11-Mar-15 10:43 
GeneralRe: Naming conventions, FP ain't got none... Pin
newton.saber11-Mar-15 11:12
newton.saber11-Mar-15 11:12 
JokeRe: Naming conventions, FP ain't got none... Pin
Daniel Pfeffer12-Mar-15 1:44
professionalDaniel Pfeffer12-Mar-15 1:44 
GeneralRe: Naming conventions, FP ain't got none... Pin
Sander Rossel11-Mar-15 10:29
professionalSander Rossel11-Mar-15 10:29 
GeneralRe: Naming conventions, FP ain't got none... Pin
Mark_Wallace11-Mar-15 12:00
Mark_Wallace11-Mar-15 12:00 
GeneralRe: Naming conventions, FP ain't got none... Pin
PhilLenoir12-Mar-15 3:47
professionalPhilLenoir12-Mar-15 3:47 
GeneralWhat a pain it's been Pin
#realJSOP11-Mar-15 8:12
professional#realJSOP11-Mar-15 8:12 
GeneralRe: What a pain it's been Pin
Sander Rossel11-Mar-15 9:04
professionalSander Rossel11-Mar-15 9:04 
GeneralRe: What a pain it's been Pin
Slacker00711-Mar-15 9:19
professionalSlacker00711-Mar-15 9:19 
GeneralRe: What a pain it's been Pin
Ian Shlasko11-Mar-15 9:21
Ian Shlasko11-Mar-15 9:21 
GeneralRe: What a pain it's been Pin
Sander Rossel11-Mar-15 9:32
professionalSander Rossel11-Mar-15 9:32 
GeneralRe: What a pain it's been Pin
Mycroft Holmes11-Mar-15 14:21
professionalMycroft Holmes11-Mar-15 14:21 
GeneralRe: What a pain it's been Pin
Kevin Marois11-Mar-15 9:48
professionalKevin Marois11-Mar-15 9:48 
GeneralRe: What a pain it's been Pin
Ian Shlasko11-Mar-15 9:20
Ian Shlasko11-Mar-15 9:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.