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

Volker Wysk <[email protected]>
Newsgroups gmane.comp.lang.mercury.general
Message-ID <[email protected]>
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

_______________________________________________
users mailing list
[email protected]
https://lists.mercurylang.org/listinfo/users
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEE6QXGh82Ov3+2nrxp+K4ydFOsHoUFAmNNXJ8ACgkQ+K4ydFOs
HoUJ8Q/8DBvwLVTLylS1EkTkqFV6IVxWTsc7PnTBaPHzuZ+mgVHDvRDHQRxIPm/s
rxa5lfqZ8y5/5rMhMJLGxFaeKs7sEzJKYpv8yuZeIHMdM6iwlEKGv4OX/fUGN5+c
6viIOgCkuvR151DkqqRuYrEMIn/5trmAqXAnEg/1G51qQUrrtc68uwcUlp02VGWZ
2ulygX84WUJhnmi/NPREBZ0yHqLELFfao6BFCqLtKt0S6bIDcH+6pp8KTy7o9J1Z
QjnibXsvZq6If05DLQVFv93QVsI1VeJi2BIXC/eC6RZkYHlH9AJRjecW3/oiyUX+
lvFAJK5H9mCInz7WMx+fCR+MYasdRMQotpic++9FX4wW1Uozv4n62/FZSUpCfeB5
P4cZDM2Sq/AIVT7tjy1mPUzA5y4wteofL2krkyIR+gGACziIpd49WfyLoj2ck+ug
uzEEW4K0mX5JfVTcXMCJ0vSlyF767fXe9n/J/DYICy/w6DVzYZrSD96z/nqp8gBr
/zBrQ6E4t+DJWE8CV6KW9dNSkHBLLmnJySXpgvCfdYCe9taSBbvlHmoDM9adWE0X
ufBNUBTty5EL6bAW+i4rv58IR3mGA1C7wiF9kUsvCLuTvQFmOXvbQIyAjNBNCWOk
rVlxgh/ISjGYCFsOfNmLmwRHDJlnNyA2rRcwwjUZnS8LbIYsbN0=
=Vzwm
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.