Files
ChaiScript/samples/bind.chai
2009-06-25 23:14:46 +00:00

32 lines
567 B
ChaiScript

//This is a cheater function. The entire point of it is to return a variable
// with an unspecified type.
// The bind function will substitute any unknown object with those passed in
def _()
{
var i;
return i;
}
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));