public void ComposeTwoFunctionalParametersUsingBindApply() { IFunction composed = new ComposeFunction(new ParameterFunction(0, 1), new ParameterFunction(1, 1)); IFunction bound = composed.Bind(new IFunction[] { new IncrementFunction(), new IncrementFunction() }); IFunction result = bound.Apply(new ConstantFunction(1)); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(ConstantFunction)); Assert.AreEqual(3, result.Value); }
public void ComposeFunctions() { IFunction incr = new IncrementFunction(); IFunction compose = new ComposeFunction(incr, incr); Assert.AreEqual(1, compose.Arity); Assert.AreEqual(compose, compose.Value); IFunction result = compose.Apply(new ConstantFunction(1)); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(ConstantFunction)); Assert.AreEqual(3, result.Value); }