开发者

Prolog append list in 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜