im trying to grab some basic prolog but struggling a bit. in the specific one, im trying to get a list of elements and copy it, by elements, to a new list. I can make him turn back, but I found that he does it without a reverse.
I am trying to do 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 that the individual elements are copied, but they are "lost" and do not form a growing list (on R, as I hoped). How could I do this?
Many thanks
source
share