예제 #1
0
        public static IEnumerable <string> Variables(IExpr expr)
        {
            if (expr.IsSymbol())
            {
                yield return(expr.SymbolValue());
            }
            if (expr.IsFunc())
            {
                var func = expr as Function;

                if (!func.IsBinary)
                {
                    foreach (var variable in Variables(func.FirstArgument))
                    {
                        yield return(variable);
                    }
                }
                else
                {
                    foreach (var variable in Variables(func.FirstArgument).Concat(Variables(func.SecondArgument)))
                    {
                        yield return(variable);
                    }
                }
            }
        }
예제 #2
0
        public static IEnumerable<string> Variables(IExpr expr)
        {
            if (expr.IsSymbol())
                yield return expr.SymbolValue();
            if (expr.IsFunc())
            {
                var func = expr as Function;

                if (!func.IsBinary)
                {
                    foreach(var variable in Variables(func.FirstArgument))
                        yield return variable;
                }
                else
                {
                    foreach (var variable in Variables(func.FirstArgument).Concat(Variables(func.SecondArgument)))
                        yield return variable;
                }
            }
        }