Learning this very slowly… got some books today and they just plain suck..
so.. I’m trying to move X position through a list.. then return the remainder of the list. Problem being I’m returning merely the element at that position rather than the list. I believe my problem is either the base case or the unknown variable. I’m also not 100% sure when the “_” should be used..
an explanation would be extremely helpful.. thanx in advance.
move([X|_],0,X).
move([X|XS],K,L) :- K>0,
K1 is K-1, move(XS,K1,L).
The base case should be
move(X,0,X).move([X|_],0,X)will unify X with the single element at the head of the list.