I'm working on an assignment where I have created a parser for a prefix-notation arithmetic language. I need to write a predicate which builds an ast for any given value V (i.e. generate an ast A such that whenever A is evaluated it's value is V). My idea was simple enough:
genAst(Val, Env, Ast) :-
ev(Ast, Env, Val).
where ev is the evaluate-predicate. When I run this I get the error on the title concerning this part of the ev-predicate:
ev(xer_(power(N)), Env, V) :-
integer(N),
V is Env^N. %THIS LINE
where both V and N are unbound. I'm struggling to think of another elegant way to do this, does anyone know how I could make prolog generate integers for these two variables?
I hope this was understandable :)