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].
精彩评论