removeAll(X, [ X | T], [ H1 | T1 ] ):-
( member ( X , T )
-> removeAll ( X , T , [ H1 | T1 ] )
;[ H1 | T1 ] is T
).
removeAll ( X , [ H | T ] , L ):-
removeAll ( X , T , L2 ), append ( [ H ] , L2 , L ).
Run Code Online (Sandbox Code Playgroud)
如果我通过“ removeAll(2,[1,1,2],L).”,
它会给出错误“ ERROR: is/2: Type error: 'evaluable' expected, found …
prolog ×1