Question: Write a Prolog relation eval ( E , V ) that evaluates integer arithmetic expressions consisting of integer constants and operators + , - ,
Write a Prolog relation evalEV that evaluates integer arithmetic expressions consisting of integer constants and operators to a constant value. The first argument E is an arbitrary arithmetic expression, and the second argument V is the single integer value resulting from evaluating the entire expression E Some tests to get started:
eval Y
Y
eval Y
Y
eval Y
Y
Write a Prolog relation simplifyES that simplifies polynomial arithmetic expressions involving constants, variables which are Prolog atoms that start with a lowercase letter and operators The first argument E is a polynomial arithmetic expression, and the second argument is the simplified expression, which must be expressed in canonical form for example, xx Handle multiplying, dividing by or adding or subtracting xx xx x x
Some tests to get started:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
