I know if I do:
[H|T] = [a,b,c,d].
H = a,
T = [b,c,d].
What I'm trying to do is get the head and tail of a list inside a rule. Is this possible? I'm setting up base cases for a recursive call but for now I'd be satisfied if it just returned L3 as a append of the first list head and the second list head. I'm just not sure how I can get the head and list.
compose([], L1, L1).
compose(L2, [], L2).
compose([], [], []).
compose(L1, L2, L3) :-
[H1|T1] = L1,
[H2|T2] = L2,
append(H1, H2, L3).
I've also tried doing below based on what I've seen online:
compose([], L1, L1).
compose(L2, [], L2).
compose([], [], []).
compose([H1|T1], [H2|T2], L3) :-
append(H1, H2, L3).
but the trace fails on the Call to this predicate.In a successful case I would like it to do the following:
compose([a,b,c], [d,e,f], L).
L = [a, d].
at the very least for now.