public static int GetParamHashCode(MeVariable[] parameters, bool paramCount = true) { if (paramCount) { return(MeArray.GetTypeHashCode(parameters)); } return(Operation.GetDynamicParameterAmountHashCode(parameters[0].GetType())); }
public MaxFunction() { Max = Utils.MakeFunction(LConstants.MAX_F, (values, func) => { func.CheckParamCount(values.Length); float[] parameters = MeArray.ToFloatArray(values); MeNumber maxNumber = parameters.Max(); return(maxNumber); }, CommonParamTypes.SingleNumber, CommonValidators.NumberArray, false); }
public MinFunction() { Min = Utils.MakeFunction(LConstants.MIN_F, (values, func) => { func.CheckParamCount(values.Length); float[] parameters = MeArray.ToFloatArray(values); MeNumber result = parameters.Min(); return(result); }, CommonParamTypes.SingleNumber, CommonValidators.NumberArray, false); }
public void CanAddSingleParameterCountFunctionAndRetrieveIt() { LanguageDefiner definer = new LanguageDefiner(); IFunctionDefiner func = new NonNegFunction(); func.AddFunction(definer); MeVariable[] vars = { new MeNumber(100) }; MeVariable[] vars2 = { new MeNumber(-30) }; int hash1 = MeArray.GetTypeHashCode(vars); int hash2 = MeArray.GetTypeHashCode(vars2); Function retFunc = definer.GetFunction(LConstants.NON_NEG_F, vars); Function retFunc2 = definer.GetFunction(LConstants.NON_NEG_F, vars2); Assert.IsNotNull(retFunc); Assert.IsNotNull(retFunc2); Assert.AreEqual(retFunc, retFunc2); }
private int CalcHashCode() { return(_hasParamCount ? MeArray.GetHashCode(AcceptedTypes) : GetDynamicParameterAmountHashCode(AcceptedTypes[0])); }