I'm trying to find a way to append a list to all lists within a list.
Something like:
appendAll([a,b],[[q,w],[z,x]],X).
X = [[a,b,q,w],[a,b,z,x]].
I'm still new to prolog and nested lists are throwing me off quite a bit.
I've been staring at this for a few hours now:
appendAll([], _, []).
appendAll(_, [], []).
appendAll([H1|T1], [H2|T2], X) :-
append(H1,H2,R),
appendAll(T1,[H2|T2],X).
% recurse down to [], and append back up
Any help is much appreciated Thanks!