lojix/prolog/src/main/com/thesett/aima/logic/fol/prolog/builtins/BuiltInUtils.java
static NumericType evaluateAsNumeric(Term numeric)
    {
        // Evaluate the expression.
        Term expressionValue = numeric.getValue();

        // Ensure that the result of evaluating the expression is a number.
        if (expressionValue.isVar())
        {
            throw new IllegalStateException("instantiation_error, 'is' expects a fully instantiated term to unify against.");
        }

        if (!expressionValue.isNumber())
        {
            throw new IllegalStateException("arithmetic_error, 'is' expectes a numeric expression to unify against.");
        }

        return (NumericType) expressionValue;
    }
static NumericType evaluateAsNumeric(Term numeric)
    {
        // Evaluate the expression.
        Term expressionValue = numeric.getValue();

        // Ensure that the result of evaluating the expression is a number.
        if (expressionValue.isVar())
        {
            throw new IllegalStateException("instantiation_error, 'is' expects a fully instantiated term to unify against.");
        }

        if (!expressionValue.isNumber())
        {
            throw new IllegalStateException("arithmetic_error, 'is' expectes a numeric expression to unify against.");
        }

        return (NumericType) expressionValue;
    }
static NumericType evaluateAsNumeric ( Term numeric ) { // Evaluate the expression. Term expressionValue = numeric . getValue ( ) ; // Ensure that the result of evaluating the expression is a number. if ( expressionValue . isVar ( ) ) { throw new IllegalStateException ( "instantiation_error, 'is' expects a fully instantiated term to unify against." ) ; } if ( ! expressionValue . isNumber ( ) ) { throw new IllegalStateException ( "arithmetic_error, 'is' expectes a numeric expression to unify against." ) ; } return ( NumericType ) expressionValue ; }
Evaluates a term by invoking its {@link Term#getValue()} method (which may cause a recursive evaluation, for
example, in the case of arithmetic expressions), and checks that the result is a fully instantiated numeric
value.

@param  numeric The term to evaluate as a number.

@return The term as a number.
Evaluates a term by invoking its { @link Term#getValue () } method ( which may cause a recursive evaluation for example in the case of arithmetic expressions ) and checks that the result is a fully instantiated numeric value .