Alex Rivera | Logout

How can currying be done in C++?

Asked 2008-09-30T06:51:54.217
66

What is currying?

How can currying be done in C++?

Please Explain binders in STL container?

Edit
Report

2 Answers

15

Have a look at Boost.Bind which makes the process shown by Greg more versatile:

transform(a.begin(), a.end(), back_inserter(b), bind(f, _1, 5));

This binds 5 to f's second argument.

It’s worth noting that this is not currying (instead, it’s partial application). However, using currying in a general way is hard in C++ (in fact, it only recently became possible at all) and partial application is often used instead.

answered 2008-09-30T08:44:25.770
2

These Links are relevant:

The Lambda Calculus page on Wikipedia has a clear example of currying
http://en.wikipedia.org/wiki/Lambda_calculus#Motivation

This paper treats currying in C/C++
http://asg.unige.ch/site/papers/Dami91a.pdf

answered 2011-10-29T18:19:51.390

Your Answer