bug-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sublist/2 recognizes subsequences as sublists


From: Daniel Diaz
Subject: Re: sublist/2 recognizes subsequences as sublists
Date: Mon, 9 Jul 2012 13:52:05 +0200

Hello,

You are right. In gprolog, sublist(L1, L2) succeeds if all elements of L1 
appear in L2 in the same order. I agree the name is confusing but this is 
compatible with SICStus, YAP and hProlog (others ?).

Anyway I have to update the doc which is erroneous.

Daniel



Le 7 juil. 2012 à 01:28, Heiko a écrit :

> Hello Daniel,
> 
> thanks for your work!
> 
> I think I have found a bug.
> 
> At least the sublist/2 predicate does not what i would expect.
> I get the effect of an subsequence instead of a sublist.
> 
> I also consulted the manual, which lapidarly states
> List processing
> 
> sublist(List1, List2) succeeds if List1 is a sub-list of List2. This 
> predicate is re-executable on backtracking.
> 
> So what is a sub-list?
> 
> GNU Prolog 1.4.1
> By Daniel Diaz
> Copyright (C) 1999-2012 Daniel Diaz
> | ?- sublist([ll,r],[ll,l,rr,r]).
> 
> true ?
> 
> yes
> | ?- sublist([l,r],[ll,l,rr,r]).
> 
> true ?
> 
> yes
> | ?- sublist([rr,r],[ll,l,rr,r]).
> 
> true ?
> 
> yes
> | ?-
> 
> I would consider only the result from the last call
> "sublist([rr,r],[ll,l,rr,r])." correct,
> since the first argument is a true sublist here.
> The others calls should give a 'no' result, since there are
> other elements ([l,rr] and [rr]) inserted.
> 
> I experimented with other sublist definitions also.
> This definition of a sublist/2 predicate
> 
> sublist(S,L):-append(_,S,P),append(P,_,L).
> 
> from here
> http://kti.mff.cuni.cz/~bartak/prolog.old/learning/LearningProlog2.html
> exhausts all stack when the S argument is not a sublist of L (instead of 
> 'no').
> 
> The following definition however works as expected:
> 
> sublist3(S,L):-prefix(S,L).
> sublist3(S,[_|T]):-sublist3(S,T).
> 
> The expectation is that the calls with first two argument settings
> should yield 'no' and the last should yield 'yes'.
> 
> My machine:
> Windows XP SP3, AMD Athlon 2GHz, 3 GB RAM
> 
> I am using the MSVC-precompiled binary of GNU Prolog version 1.4.1 from the 
> gnuprolog website.
> 
> Thanks for your attention and greetings,
> Heiko Eißfeldt
> 
> 
> _______________________________________________
> Bug-prolog mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/bug-prolog
> 
> -- 
> Ce message a ete verifie par MailScanner
> pour des virus ou des polluriels et rien de
> suspect n'a ete trouve.
> 


-- 
Ce message a ete verifie par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a ete trouve.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]