I'm blocking on a predicate to code in Prolog. I need to code that two predicates:
If I call : u([a,b,c,d,e,f], X).
it will give X=[a,b], X=[b,c], X=[c,d]
...
If I call : v([a,b,c,d,e,f], X).
it will give X=[a,b], X=[c,d], X=[e,f]
...
Thanks a lot!
u(L,P) :- ([ [P,P] | L ], P).
But ... I've got no idea, I think the solution is simple ... I need to use recursivity – CounterchangeL
with a list[First, Second | Tail]
. – Joanniejoao