Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sys27 committed Jun 7, 2017
1 parent 195ebb9 commit df86115
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions xFunc.Maths/Analyzers/TypeAnalyzer.cs
Expand Up @@ -53,7 +53,7 @@ private ResultType CheckTrigonometric(UnaryExpression exp)
if (result == ResultType.ComplexNumber)
return ResultType.ComplexNumber;

throw new ParameterTypeMismatchException();
throw new ParameterTypeMismatchException(ResultType.Number | ResultType.ComplexNumber, result);
}

private ResultType CheckStatistical(DifferentParametersExpression exp)
Expand All @@ -62,13 +62,19 @@ private ResultType CheckStatistical(DifferentParametersExpression exp)
if (results == null || results.Contains(ResultType.Undefined))
return ResultType.Undefined;

if (results.Count == 1 && (results[0] == ResultType.Number || results[0] == ResultType.Vector))
return ResultType.Number;
if (results.Count == 1)
{
if (results[0] == ResultType.Number || results[0] == ResultType.Vector)
return ResultType.Number;

if (results.All(x => x == ResultType.Number))
return ResultType.Number;
throw new ParameterTypeMismatchException();
}

throw new ParameterTypeMismatchException();
for (var i = 0; i < results.Count; i++)
if (results[i] != ResultType.Number)
throw new ParameterTypeMismatchException();

return ResultType.Number;
}

#region Standard
Expand Down

0 comments on commit df86115

Please sign in to comment.