Determining whether items are functions, or arrays, etc.

ID: 47

				
					using uCalcSoftware;

var uc = new uCalc();
uc.DefineVariable("MyVar");

Console.WriteLine($"{uc.EvalStr("'Cos is a function? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.Function)}");
Console.WriteLine($"{uc.EvalStr("'Cos is a variable? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.Variable)}");
Console.WriteLine($"{uc.EvalStr("'Cos is an operator? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.Operator)}");
Console.WriteLine($"{uc.EvalStr("'MyVar is a function? '")}{uc.ItemOf("MyVar").IsProperty(ItemIs.Function)}");
Console.WriteLine($"{uc.EvalStr("'MyVar is a variable? '")}{uc.ItemOf("MyVar").IsProperty(ItemIs.Variable)}");
Console.WriteLine($"{uc.EvalStr("'MyVar is an operator? '")}{uc.ItemOf("MyVar").IsProperty(ItemIs.Operator)}");
Console.WriteLine($"{uc.EvalStr("'+ is a function? '")}{uc.ItemOf("+").IsProperty(ItemIs.Function)}");
Console.WriteLine($"{uc.EvalStr("'+ is a variable? '")}{uc.ItemOf("+").IsProperty(ItemIs.Variable)}");
Console.WriteLine($"{uc.EvalStr("'+ is an operator? '")}{uc.ItemOf("+").IsProperty(ItemIs.Operator)}");
Console.WriteLine($"{uc.EvalStr("'Cos not found? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.NotFound)}");
Console.WriteLine($"{uc.EvalStr("'XYZABC not found? '")}{uc.ItemOf("XYZABC").IsProperty(ItemIs.NotFound)}");
				
			
Cos is a function? True
Cos is a variable? False
Cos is an operator? False
MyVar is a function? False
MyVar is a variable? True
MyVar is an operator? False
+ is a function? False
+ is a variable? False
+ is an operator? True
Cos not found? False
XYZABC not found? True
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

#define tf(IsTrue) ((IsTrue) ? "True" : "False")

int main() {
   uCalc uc;
   uc.DefineVariable("MyVar");

   cout << uc.EvalStr("'Cos is a function? '") << tf(uc.ItemOf("Cos").IsProperty(ItemIs::Function)) << endl;
   cout << uc.EvalStr("'Cos is a variable? '") << tf(uc.ItemOf("Cos").IsProperty(ItemIs::Variable)) << endl;
   cout << uc.EvalStr("'Cos is an operator? '") << tf(uc.ItemOf("Cos").IsProperty(ItemIs::Operator)) << endl;
   cout << uc.EvalStr("'MyVar is a function? '") << tf(uc.ItemOf("MyVar").IsProperty(ItemIs::Function)) << endl;
   cout << uc.EvalStr("'MyVar is a variable? '") << tf(uc.ItemOf("MyVar").IsProperty(ItemIs::Variable)) << endl;
   cout << uc.EvalStr("'MyVar is an operator? '") << tf(uc.ItemOf("MyVar").IsProperty(ItemIs::Operator)) << endl;
   cout << uc.EvalStr("'+ is a function? '") << tf(uc.ItemOf("+").IsProperty(ItemIs::Function)) << endl;
   cout << uc.EvalStr("'+ is a variable? '") << tf(uc.ItemOf("+").IsProperty(ItemIs::Variable)) << endl;
   cout << uc.EvalStr("'+ is an operator? '") << tf(uc.ItemOf("+").IsProperty(ItemIs::Operator)) << endl;
   cout << uc.EvalStr("'Cos not found? '") << tf(uc.ItemOf("Cos").IsProperty(ItemIs::NotFound)) << endl;
   cout << uc.EvalStr("'XYZABC not found? '") << tf(uc.ItemOf("XYZABC").IsProperty(ItemIs::NotFound)) << endl;
}
				
			
Cos is a function? True
Cos is a variable? False
Cos is an operator? False
MyVar is a function? False
MyVar is a variable? True
MyVar is an operator? False
+ is a function? False
+ is a variable? False
+ is an operator? True
Cos not found? False
XYZABC not found? True
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      uc.DefineVariable("MyVar")
      
      Console.WriteLine($"{uc.EvalStr("'Cos is a function? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.Function)}")
      Console.WriteLine($"{uc.EvalStr("'Cos is a variable? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.Variable)}")
      Console.WriteLine($"{uc.EvalStr("'Cos is an operator? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.Operator)}")
      Console.WriteLine($"{uc.EvalStr("'MyVar is a function? '")}{uc.ItemOf("MyVar").IsProperty(ItemIs.Function)}")
      Console.WriteLine($"{uc.EvalStr("'MyVar is a variable? '")}{uc.ItemOf("MyVar").IsProperty(ItemIs.Variable)}")
      Console.WriteLine($"{uc.EvalStr("'MyVar is an operator? '")}{uc.ItemOf("MyVar").IsProperty(ItemIs.Operator)}")
      Console.WriteLine($"{uc.EvalStr("'+ is a function? '")}{uc.ItemOf("+").IsProperty(ItemIs.Function)}")
      Console.WriteLine($"{uc.EvalStr("'+ is a variable? '")}{uc.ItemOf("+").IsProperty(ItemIs.Variable)}")
      Console.WriteLine($"{uc.EvalStr("'+ is an operator? '")}{uc.ItemOf("+").IsProperty(ItemIs.Operator)}")
      Console.WriteLine($"{uc.EvalStr("'Cos not found? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.NotFound)}")
      Console.WriteLine($"{uc.EvalStr("'XYZABC not found? '")}{uc.ItemOf("XYZABC").IsProperty(ItemIs.NotFound)}")
   End Sub
End Module
				
			
Cos is a function? True
Cos is a variable? False
Cos is an operator? False
MyVar is a function? False
MyVar is a variable? True
MyVar is an operator? False
+ is a function? False
+ is a variable? False
+ is an operator? True
Cos not found? False
XYZABC not found? True