0

So i have this predicate that has to succeed when L is the concatenation of the other two lists, X and Y. Apparently it doesn't work yet. The question is how could i fix the code fragment. Being new to Prolog i still am not sure how can i implement this correctly, having worked only with procedural programming until now.

% concat(L,X,Y) returns true if L is the concatenation of the lists X and Y

concat([],L,L).
concat([X1|L1],L2,[X1|L3]) :- concat(L1, L2, L3).
false
  • 10,264
  • 13
  • 101
  • 209
Cornul11
  • 191
  • 1
  • 12
  • 3
    It seems that you concatenate `L` and `X` with your current code. – Kirill Bulygin Jun 06 '18 at 12:56
  • https://stackoverflow.com/questions/10620011/explanation-of-a-prolog-algorithm-to-append-two-lists-together?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – bob_saginowski Jun 06 '18 at 18:58

0 Answers0