0

I need to write a program in swi-prolog that removes the second value of a list. thanks!

4

1 回答 1

3

我认为这可能很简单:

remove2nd([], []).
remove2nd([X], [X]).
remove2nd([X, Y|Z], [X|Z]).

你在哪里使用它:

remove2nd([1,2,3], X).

并给你

X = [1, 3].
于 2012-04-22T21:15:55.023 回答