I have a prolog assignment.
I need to look at the first item in a list, see if its following items are the same until they are not and separate the lists by the firs
Here is another solution that takes into account what @Sarah wrote. Given this use, grab/3 should never succeed for an empty list for the first or second argument.
grab([A], [A], []).
grab([A,B|Bs], [A], [B|Bs]) :-
dif(A,B).
grab([A,A|Xs], [A|As], Bs) :-
grab([A|Xs], As, Bs).
?- Xs = [A,B], grab(Xs,Ys,Zs).
Xs = [A, B], Ys = [A], Zs = [B], dif(A, B)
; Xs = Ys, Ys = [B, B], Zs = [], A = B
; false.