Logo

Programming-Idioms

History of Idiom 37 > diff from v2 to v3

Edit summary for version 3 by :

Version 2

2015-07-31, 20:08:41

Version 3

2015-08-20, 17:17:06

Idiom #37 Currying

Technique of transforming a function that takes multiple arguments and returning a function for which some of the arguments are preset.

Idiom #37 Currying

Technique of transforming a function that takes multiple arguments and returning a function for which some of the arguments are preset.

Imports
import std.functional;
Code
int add(int n1, int n2)
{
	return n1 + n2;
}

alias add5 = curry!(add, 5);
Comments bubble
`curry` also supports multiple arguments.
Demo URL
http://dpaste.dzfl.pl/6cceb5d75a7c