Prolog - 为什么我对append_list的定义不返回组合列表?

时间:2017-10-06 20:53:04

标签: prolog

% appends an element to the beginning of a list. 

append_element(X, T, [X|T]).

% append a list to another list to create a combined list,
% by breaking the first list apart, and using append_element.

append_list([], L, L).

append_list([H|T], L, NewList) :- 
    append_element(H, L, NL), 
    append_list(T, NL, NL).

当我尝试运行append_list时,

?- append_list([1,2], [3, 4, 5], NL).

我回来假。而不是

NL = [2, 1, 3, 4, 5].

为什么?

0 个答案:

没有答案