Skip to content

Instantly share code, notes, and snippets.

@lukhnos lukhnos/curry1.m
Created Feb 8, 2012

Embed
What would you like to do?
Using Objective-C block to curry a function, take 1
#include <stdio.h>
int f(int x, int y)
{
return x + y;
}
int main()
{
typedef int (^int_to_int_t)(int);
typedef int_to_int_t (^int_to_int_to_int_t)(int);
int_to_int_to_int_t h = ^(int x) {
int_to_int_t g = ^(int y) {
return f(x, y);
};
return g;
};
int_to_int_t g = h(5);
int z;
z = g(10);
printf("%d\n", z);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.