我一直試圖在序言中做不同的事情,並想刪除最後一個元素,但我不知道如何。需要刪除序列中的最後一個元素
這是我的代碼:
without(X,[X,_],[]).
without(X,[K|Xs],[K|AlmoustLast]) :-
without(X,Xs,AlmoustLast).
這是編譯時我收到。
?- without(X,[1,2,3,4,5],A).
X = 4,
A = [1, 2, 3] .
當我試圖達到的answear是A = [1,2,3,5]。
[相關](http://stackoverflow.com/q/36685680/772868)。 – false
看看沒有(1,[1,2],L)'! – false