Given
Result = 4* (3*x)^3*3,
and
VarValue = x:2,
How can I get the following output
Value = 2592 ;
if I have to defined the following predicate:
evaluate(Result,Value,VarValue)
I tried doing the following:
evaluate(Result, Value, VarValue) :- member(VarValue, [x:X]).
and trying to substitute X into the equation.. I could not think of a nice way to go from there.
EDIT: Is there a way to only use the following built-predicates :
//, /, +, -, ^, *,=..,>, <,
atom, is_list, functor, arg, integer, number, member, append
I think joel76 solution can be made a bit more compact:
Here is something to get you started. It supports only addition and subtraction, and no braces. Adding more operations is trivial, adding braces support is more tricky.
Let's try it:
You can use =.. :
For example :
EDIT I remove member(Term:(V), LstVars) -> R = (V) wich is useless.