I need to merge two lists L1=[1,2,3] and L2=[a,b] like this: M=[1,a,2,b,3]. How can I do it in PROLOG please?
you can try
m2([A|As], [B|Bs], [A,B|Rs]) :-
!, m2(As, Bs, Rs).
m2([], Bs, Bs) :- !.
m2(As, [], As).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With