Some data-type check functions (e.g. IsInteger()) exported
This commit is contained in:
+7
-7
@@ -28,17 +28,17 @@ func evalPlus(ctx ExprContext, self *term) (v any, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
if (isString(leftValue) && isNumberString(rightValue)) || (isString(rightValue) && isNumberString(leftValue)) {
|
||||
if (IsString(leftValue) && isNumberString(rightValue)) || (IsString(rightValue) && isNumberString(leftValue)) {
|
||||
v = fmt.Sprintf("%v%v", leftValue, rightValue)
|
||||
} else if isNumber(leftValue) && isNumber(rightValue) {
|
||||
if isFloat(leftValue) || isFloat(rightValue) {
|
||||
} else if IsNumber(leftValue) && IsNumber(rightValue) {
|
||||
if IsFloat(leftValue) || IsFloat(rightValue) {
|
||||
v = numAsFloat(leftValue) + numAsFloat(rightValue)
|
||||
} else {
|
||||
leftInt, _ := leftValue.(int64)
|
||||
rightInt, _ := rightValue.(int64)
|
||||
v = leftInt + rightInt
|
||||
}
|
||||
} else if isList(leftValue) || isList(rightValue) {
|
||||
} else if IsList(leftValue) || IsList(rightValue) {
|
||||
var leftList, rightList *ListType
|
||||
var ok bool
|
||||
if leftList, ok = leftValue.(*ListType); !ok {
|
||||
@@ -56,7 +56,7 @@ func evalPlus(ctx ExprContext, self *term) (v any, err error) {
|
||||
}
|
||||
v = &sumList
|
||||
} else if isFraction(leftValue) || isFraction(rightValue) {
|
||||
if isFloat(leftValue) || isFloat(rightValue) {
|
||||
if IsFloat(leftValue) || IsFloat(rightValue) {
|
||||
v = numAsFloat(leftValue) + numAsFloat(rightValue)
|
||||
} else {
|
||||
v, err = sumAnyFract(leftValue, rightValue)
|
||||
@@ -87,7 +87,7 @@ func evalMinus(ctx ExprContext, self *term) (v any, err error) {
|
||||
}
|
||||
|
||||
if isNumOrFract(leftValue) && isNumOrFract(rightValue) {
|
||||
if isFloat(leftValue) || isFloat(rightValue) {
|
||||
if IsFloat(leftValue) || IsFloat(rightValue) {
|
||||
v = numAsFloat(leftValue) - numAsFloat(rightValue)
|
||||
} else if isFraction(leftValue) || isFraction(rightValue) {
|
||||
v, err = subAnyFract(leftValue, rightValue)
|
||||
@@ -96,7 +96,7 @@ func evalMinus(ctx ExprContext, self *term) (v any, err error) {
|
||||
rightInt, _ := rightValue.(int64)
|
||||
v = leftInt - rightInt
|
||||
}
|
||||
} else if isList(leftValue) && isList(rightValue) {
|
||||
} else if IsList(leftValue) && IsList(rightValue) {
|
||||
leftList, _ := leftValue.(*ListType)
|
||||
rightList, _ := rightValue.(*ListType)
|
||||
diffList := make(ListType, 0, len(*leftList)-len(*rightList))
|
||||
|
||||
Reference in New Issue
Block a user