Boundary conditions
Bengbers <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
I am a novice to Prolog so please excuse this maybe stupid question.
I have two lists:
Control = [1,2,3,4]
Check = [4,5,6]
and I am looking for those items in Check that are not member from Control
([5,6])
I have written the following code:
1 uniques_list( Control, Check, Unique) :- uniques_list( Control, Check, [],
Unique).
2 uniques_list( Control, [H|Tail], Accu, Unique) :-
\+member( H, Control), Accu2=[H|Accu], uniques_list( Control, Tail,
Accu2, Unique).
3 uniques_list( Control, [_|Tail], Accu, Unique) :-
uniques_list( Control, Tail, Accu, Unique).
4 uniques_List( Control, [], Unique, Unique).
When calling uniques_list( [1,2,3,4], [ 4,5,6], X) and tracing the code, I
see at some moment that Accu contains [5,6] and that the tail is [].
I would expect that the flow continues to line 4 and that the call returns
but instead it continues with line 2.
My questions are:
- How can I fix this (and let X unify with [5,6])?
- What are the boundary conditions (why doesn't the flow jump to line 4)?
Ben
--
View this message in context: http://swi-prolog.996271.n3.nabble.com/Boundary-conditions-tp13445.html
Sent from the SWI Prolog mailing list archive at Nabble.com.