merge lists in lists with special format
merge lists in lists with special format I have the following format in Prolog: cars([car([...])]) cars([car([...])]) I would like to merge two cars lists. cars I tried: mergelist(cars(),L,L). mergelist(cars([car(Car_i)|Cars_i]),Cars_j,cars([car(Car_i)|List])) :- mergelist(cars(Car_i),Cars_j,cars(List)). But it doesn't work. I would like the following example to work: mergelist(cars([car([type([95], 2.0), type([120], 5.0), type([121], 10.0)]), car([type([95], 0.4), type([120], 1.0), type([121], 2.0)])]), cars(car([type([95], 2.0)])),Result). The output will be: Result = cars([car([type([95], 2.0), type([120], 5.0), type([121], 10.0)]), car([type([95], 0.4), type([120], 1.0), type([121], 2.0)])]), cars(car([type([95], 2.0)]), car([type([95], 2.0)])). How can I do it? merglist(cars(), L, L). has first argument is cars(X) where X is a list. mergelist(cars([car(Car_i)|Cars_i]),...) :- has first element cars(X) where X is a list. However, in your ...