public Expression CreatePair(BuiltinPair pair) { return new FreeSymbolExpression { Name = "_Pair", Tag = pair, Display = _PairDisplay }; }
public static bool RecognizePair(Expression expression, out BuiltinPair value) { // \f.f <FIRST> <SECOND> is Pair value = null; if (expression is AbstractionExpression) { var abs = (AbstractionExpression)expression; if (abs.Right is ApplicationExpression) { var app1 = (ApplicationExpression)abs.Right; if (app1.Left is ApplicationExpression) { var app2 = (ApplicationExpression)app1.Left; if (app2.Left is BoundSymbolExpression) { var bound = (BoundSymbolExpression)app2.Left; if (bound.Symbol == abs.Left) { // Pair value = new BuiltinPair { First = app2.Right, Second = app1.Right }; return true; } } } } } return false; }