I have list of elements in a list like [1,2,+]
and I want to push them as a one element onto a stack. I can do that by putting them between square brackets but this will make brackets appear in the output. For Example, I want to push the elements of the list [1,2,+] onto a stack:
stack([1,2,+],S,Y).
Where stack
is:
stack(T,S,[T|S]).
The problem is that if I push more expressions onto the stack, they will have nested brackets. For example, I would get [[+,1,2],[*,3,4]]
, but I want [+,1,2,*,3,4]
. How can I accomplish this?