I’m trying to format a result from a program but getting an hard time.
I wanted to give something like this as result:
Res = do(paint(x) do(clean(a), do(repair(b) , initialState)))
basically, I want to concatenate successive terms to initialState atom but, it doesn’t work with atom_concat since the other terms to concatenate aren’t atoms and also I wanted to add the ) everytime I pass through the “do” function.
So it would be something like: Res = initialState.
When do function was called, I would have a function like
concatenateTerm(Pred, Res, Res).
Pred beeing repair(b) for instance and obtain the result: res = do(repair(b), initialState).
Is this possible to be done?
Thanks
If I understand you correctly you need to do something like:
where you final result is in
Res3. Remember prolog procedures don’t “return” anything and input and output values must be passed through arguments.Why do you want to concatenate successive terms to the atom
initialState? Thi is not the prolog way. It would be much more natural in prolog to build a structure which is modified each time.