'Prolog - Appending to the same list over and over
I have a list which is initially empty in Prolog
movements([]).
Now, I want to append an action to movements list.
process :-
movements(List),
append(L,[forward],X).
To my understanding, append creates a new list X which will append forward into the empty list, giving me X = [forward]. However this is not I want since I might be appending to the same list over and over again using a for loop. What I need is the original list in movements to be = [forward] instead. Calling process another time should give me movements = [forward,forward]. How do I go about doing so?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
