public Apply ( Context context, IList | ||
context | Context | |
arguments | IList | |
return | object |
public object Apply(Context context, IList<object> arguments)
{
foreach (var function in this.functions)
{
var newcontext = function.MakeContext(arguments);
if (newcontext != null)
return function.Evaluate(newcontext);
}
throw new Exception("no function clause to match");
}
public void EvaluateMultiFunctionWithTwoFunctions() { Function func1 = this.MakeFunction("f(0) -> 1."); Function func2 = this.MakeFunction("f(1) -> 2."); MultiFunction mfunc = new MultiFunction(new Function[] { func1, func2 }); Assert.AreEqual(2, mfunc.Apply(null, new object[] { 1 })); }