Support cleaner usage of bind, by adding a built in _ variable
This commit is contained in:
@@ -1,19 +1,10 @@
|
||||
|
||||
//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 b = bind(add, 2, _);
|
||||
var c = bind(b, 3);
|
||||
|
||||
print(b(4));
|
||||
@@ -25,7 +16,7 @@ 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 ");
|
||||
var d = bind(concat, _, " Hello ", _, " World ");
|
||||
print(d(1, 3));
|
||||
//This checks to make sure arity is handled correctly:
|
||||
//print(d(1, 3, 4));
|
||||
|
||||
Reference in New Issue
Block a user