Reputation: 2896
I have a list of lists, I want to append more lists to it.
Suppose I have a list:
L=[[A,B],[C,D]]
I want to append a list
L1 = [E,F]
to it, how should this be done? 'append' would just put it as:
[[A,B],[C,D],E,F]
I wrote a function like this:
appendlist(New, Old, [New|Old]).
but it puts the new list before the old one, I want to reverse the order.
Upvotes: 4
Views: 6780
Reputation: 60004
Maybe a too much synthetic answer, but here it is:
?- append([[1,2],[3,4]],[[5,6]],L).
L = [[1, 2], [3, 4], [5, 6]].
Upvotes: 6