Hi
I am trying to teach myself prolog and as I am totally new to this I thought some help wouldn't be a bad idea.
My first challenge is to write a prolog predicate that takes two arguments. The first is a list and the predicate should return the list reversed as the second argument.
e.g
reverse([a,b,c,d], X).
X=[d,c,b,a]
Can anyone help to get me started?
I know a is the head and b,c,d is the tail but don't know where to go from there...
I am trying to teach myself prolog and as I am totally new to this I thought some help wouldn't be a bad idea.
My first challenge is to write a prolog predicate that takes two arguments. The first is a list and the predicate should return the list reversed as the second argument.
e.g
reverse([a,b,c,d], X).
X=[d,c,b,a]
Can anyone help to get me started?
I know a is the head and b,c,d is the tail but don't know where to go from there...