static void TestLambda() { System.Console.WriteLine("====================="); System.Console.WriteLine("Testing Lambda:"); Lambda l = new Lambda( new Variable(new E(), 0), new App( new Variable(new Arrow(new E(), new T()), 8), new Variable(new E(), 0))); System.Console.WriteLine(l); LogicalForm noChange = l.Bind(0, new Constant(new E(), 40)); System.Console.WriteLine(noChange); LogicalForm variableReplace = l.Bind(8, new Constant(new Arrow(new E(), new T()), 60)); System.Console.WriteLine(variableReplace); System.Console.WriteLine(l.Apply(new Constant(new E(), 40))); System.Console.WriteLine("====================="); }
public LogicalForm Reduce() { if (f.GetType() == typeof(Lambda)) { Lambda l = (Lambda)f; System.Console.WriteLine("the type IS a lambda"); return(l.Apply(x)); } System.Console.WriteLine("the type is NOT a lambda"); return(this); }
public void ShouldApplyValue() { Variable variableX = new Variable("x"); Variable variableY = new Variable("y"); Variable variableZ = new Variable("z"); Pair pair = new Pair(variableX, variableY); Lambda lambda = new Lambda(variableX, pair); Expression expression = lambda.Apply(variableZ); Assert.IsNotNull(expression); Assert.IsInstanceOfType(expression, typeof(Pair)); Assert.AreEqual("zy", expression.ToString()); }