ChaiScript/samples/bind.chai

23 lines
344 B
ChaiScript

def add(x, y)
{
return x + y;
}
var b = bind(add, 2, _);
var c = bind(b, 3);
print(b(4));
print(c());
def concat(a,b,c,d)
{
return to_string(a) + to_string(b) + to_string(c) + to_string(d);
}
var d = bind(concat, _, " Hello ", _, " World ");
print(d(1, 3));
//This checks to make sure arity is handled correctly:
//print(d(1, 3, 4));