[m-users.] Problem with DCG producing false negative

Volker Wysk post at volker-wysk.de
Tue Oct 18 00:46:07 AEDT 2022


Hi

You might want to try the debugger. See the chapter on debugging in the user
manual. 

You also might want to generate debugging output with "trace". See the
chapter on trace goals, also there. For instance, rename "tls" to "tls1" and
do:

:- pred tls(list(cl)::out,list(cl)::out,cl::in,cl::out) is nondet.

tls(X, Y, In, Out) :-
    tls1(X, Y, In, Out), 
    trace [io(!IO)] (io.format("X=%s\nY=%s\nIn=%s\nOut=%s\n\n", 
                    [s(string(X)), s(string(Y)), s(string(In)),            
                     s(string(Out))],  !IO), true.


Am Montag, dem 17.10.2022 um 18:31 +0530 schrieb Razetime:
> sorry for the confusion.
> 
> File: https://github.com/razetime/aoc/blob/main/16/t_a07.m
> Library: https://github.com/razetime/aoc/blob/main/16/alib.m
> 
> The use of seq is to describe a sequence of an arbitrary number of characters.
> I use it as per Markus Triska's Prolog DCG Primer:
> https://www.metalevel.at/prolog/dcg
> in order to describe that and get it as a list for future use.
> 
> The rules for a string that should be matched by tls are
> a) an [A,B,B,A] pattern outside [] must exist
> b) no [A,B,B,A] patterns must exist inside []
> 
> The use of tls is
> a) as a checking predicate to see if a string fits that spec
> b) sequences inside [] go into [Y0|Y]
> c) sequences outside [] go into [X0|X]
> I was planning to use it in filter_map, like tls(A,B,L,[]), returning
> {A,B} from the higher order predicate.

I don't see how you're trying to achieve that. "abba" isn't called at all by
"tls". 


Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mercurylang.org/archives/users/attachments/20221017/32f49035/attachment.sig>


More information about the users mailing list