removing duplicates from result - newbee

From: Antony Sequeira (usemyfullname_at_hotmail.com)
Date: 03/14/04


Date: Sun, 14 Mar 2004 22:07:37 +0000

I am learning prolog using the prolog book(1986) by Bratko.
I consult the following code

conc([],L,L).
conc([X|L1],L2,[X|L3]) :-
     conc(L1,L2,L3).

sublist(S,L) :-
     conc(_,L2,L),
     conc(S,_,L2).

I try
  sublist(X,[a,b]).
I get the following results.
?- sublist(X,[a,b]).

X = [] ;

X = [a] ;

X = [a, b] ;

X = [] ;

X = [b] ;

X = []

Is it expected behavior to get the same result (the empty list) more
than once?
Is this too early for me to be asking this question(my prolog knowledge
is limited to the first three chapters of Bratko)?
I am using SWI-Prolog version 5.2.11 on Windows 2000.

Thanks,

-- 
Antony Sequeira
use my full name at hotmail.com


Relevant Pages

  • Prolog Programming for AI, problem 7.1
    ... I'm soldiering through "Prolog Programming for Artifical Intelligence" by ... but have run into a nasty exercise. ... Write a procedure 'simplify' to symbolically simplify summation ... I doubt they're what Bratko had in mind. ...
    (comp.lang.prolog)
  • Re: removing duplicates from result - newbee
    ... >I am learning prolog using the prolog bookby Bratko. ... >Is it expected behavior to get the same result more ... If you want S to be non-empty, you can modify sublist/2 accordingly. ...
    (comp.lang.prolog)
  • Re: An innovative approach to Monkey-Banana Problem?
    ... my teacher asked me to implement the ... mr bratko did it in "prolog - programming for artificial intelligence". ... thought of making the monkey climb down the box again. ...
    (comp.ai.philosophy)
  • Re: Perfect numbers
    ... I am learning prolog by my own decision, ... I though this group might be useful, even for One More Homework, ... interested in prolog are not learning it as part of their study plans. ...
    (comp.lang.prolog)
  • Re: removing the largest item from the list
    ... >>I won't tell you the whole answer, because you are learning prolog, ... >develop total dislike of the Prolog language and it's seemingly closed ... >Is there really a desire within the Prolog Community to increase Prolog's ...
    (comp.lang.prolog)