开发者

Delete the first N elements from a list in Prolog

开发者 https://www.devze.com 2023-02-22 15:08 出处:网络
How can I delete the first N elements from a list in Prolog? How can I get the first N elements from a list into another list?

How can I delete the first N elements from a list in Prolog? How can I get the first N elements from a list into another list? I need this in order to insert a list in another list from a specified position. I already have the concatenation function and plan to get a list of the first N elements of the initial list, concatenate it with the second list, then concatenate the result with the list of the remaining elements in the first list (obtained by del开发者_如何转开发eting the first N elements).


?- length(X, 3), append(X, Y, [a,b,c,d,e,f,g,h]).
X = [a, b, c],
Y = [d, e, f, g, h].
0

精彩评论

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