Support cleaner usage of bind, by adding a built in _ variable

This commit is contained in:
Jason Turner
2009-06-29 23:00:29 +00:00
parent b3fa6405c5
commit 714e1c0cec
3 changed files with 12 additions and 13 deletions

View File

@@ -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));