/// <summary> /// User defined function example - add two numbers /// </summary> Value user_add(FunctionArguments arguments, SymbolTable symbol_table) { arguments.check_num_args(2); var val1 = arguments.get_double_argument(0, null, null, symbol_table); var val2 = arguments.get_double_argument(1, null, null, symbol_table); return(new DynamicValue(val1 + val2)); }
/// <summary> /// Object based programming example - Python side constructor. /// </summary> Value UserSum(FunctionArguments arguments, SymbolTable symbol_table) { arguments.check_num_args(1); var start = arguments.get_double_argument(0, null, null, symbol_table); return(new UserSum(start)); }
public Value call(string function_name, FunctionArguments arguments, SymbolTable symbol_table) { if (function_name.Equals("add")) { arguments.check_num_args(1); var val1 = arguments.get_double_argument(0, null, null, symbol_table); sum += val1; return(NoneValue.NONE); } else if (function_name.Equals("get")) { arguments.check_num_args(0); return(new DynamicValue(sum)); } return(null); }