im attempting to get my arms around some basic prolog but struggling a bit. in specific - im trying to got through a list of items and copy it, item by item into a new list. I can get it to reverse, but im finding it tricker doing it without reversing.
Ive been trying the following -
copy(L,R) :- accCp(L,R).
accCp([],R).
accCp([H|T],R) :- accCp(T,H).
When i run a trace on this - i can see the individual items being copied across, but they get 'lost', and dont form a growing list (at R, as i was hoping). How could i achivie this?
Many thanks