开发者

Prolog append list in a list

开发者 https://www.devze.com 2023-04-12 20:56 出处:网络
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

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.


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]].
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号