I'm new to Prolog and when I query sortedUnion ([1,1,1,2,3, 4, 4,5], [0,1,3,3,6,7], [0,1,2,3,4,5,6,7]). I get an error Exception: (7) Unify ([_G114, _G162, _G201, _G231, _G243], [_G249, _G297, _G336, _G357, _G369] ], [0, 1, 2, 3, 4, 5, 6, 7])? So I hope someone can tell me why my code is wrong and why is it wrong? % undup (L, U) keeps properly when the UL can be obtained, destroy the repeating components of the same element ([], []). UPDATE ([x | xs], [_ | B]): - Remove (x, x, k), apu (k, b). remove(_,[],[]). Remove (Y, [Y | T], D): - Remove (Y, T, D). Remove (Y, [S | T], [SR]): - No (Y = S), Remove (Y, T, R). % Holds SortedUnion (L1, L2, U), when U is an example of each element of L1 and L2 sortidunes ([H.T.T], [SR], [F | B]): [H. T.], N.), Apup ([SR], M), united (N, M, [F | B]). Unite ([], [], [] unite ([X], [], [X]) unify ([], [X], [X] unify ([H.T.T], [ SR], [X | Ax]]: - S = H, X, is united (T, R, XS). Unite ([H. T], [SR], [X | Ax]]: - H & LT; S, X is H, united...