[m-users.] Confused by action of string.prefix_length
Sean Charles (emacstheviking)
objitsu at gmail.com
Wed Jun 8 07:47:59 AEST 2022
I have this code:
:- pred pd_fence(string::in, int::out) is semidet.
pd_fence(S, N) :-
N = string.prefix_length(is_tilde, S),
N > 2,
trace[io(!Dbg)]
(
io.format("N is %i for %s\n", [i(N), s(S)], !Dbg)
).
And when I run it with some tests strings I get this output, the values seem to be exactly twice the number of tilde characters and I don’t understand why!
./classify_line '# heading1' 'plain text' '```' '```c' '```c<<*>>' '˜˜˜' '˜˜˜{.c}' '˜˜˜˜˜{.c} <<data>>' '˜˜˜˜˜{.c} <<core>>= ../src/filename.c'
plain_text => # heading1
plain_text => plain text
fence_MD(42) => ```
fence_MD(42) => ```c
fence_MD(42) => ```c<<*>>
N is 6 for ˜˜˜
fence_PD(42, 6) => ˜˜˜
N is 6 for ˜˜˜{.c}
fence_PD(42, 6) => ˜˜˜{.c}
N is 10 for ˜˜˜˜˜{.c} <<data>>
fence_PD(42, 10) => ˜˜˜˜˜{.c} <<data>>
N is 10 for ˜˜˜˜˜{.c} <<core>>= ../src/filename.c
fence_PD(42, 10) => ˜˜˜˜˜{.c} <<core>>= ../src/filename.c
Thanks,
Sean.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20220607/05589905/attachment.html>
More information about the users
mailing list