scryer-prolog icon indicating copy to clipboard operation
scryer-prolog copied to clipboard

Write option max_depth/1

Open UWN opened this issue 2 years ago • 7 comments

See GNU: https://github.com/didoudiaz/gprolog/issues/56

UWN avatar Jul 10 '23 14:07 UWN

Related: https://github.com/mthom/scryer-prolog/issues/1803

UWN avatar Jul 10 '23 14:07 UWN

A comparison with SICStus:

?- nth1(I,[1+2+3+4,_^_^_^_^_,1^2^3^4^nil,[1,2,3,4],[_,_,_,_]],T),between(0,5,D),write(I-D),write(' '),write_term(T,[max_depth(D)]),nl,false.
%   SICStus                           Scryer
1-0 1+2+3+4                       1-0 1+2+3+4
1-1 ... + ...                     1-1 ... + ... +4
1-2 ... + ... +4                  1-2 ... + ... +3+4
1-3 ... + ... +3+4                1-3 1+2+3+4
1-4 1+2+3+4                       1-4 1+2+3+4
1-5 1+2+3+4                       1-5 1+2+3+4
2-0 _1143^_1179^_1215^_1251^_1287 2-0 _535229^_535245^_535259^_535271^_535272
2-1 _1143^ ...                    2-1 _535229^ ... ^ ...
2-2 _1143^_1179^ ...              2-2 _535229^_535245^ ... ^ ...
2-3 _1143^_1179^_1215^ ...        2-3 _535229^_535245^_535259^ ... ^ ...
2-4 _1143^_1179^_1215^_1251^_1287 2-4 _535229^_535245^_535259^_535271^_535272
2-5 _1143^_1179^_1215^_1251^_1287 2-5 _535229^_535245^_535259^_535271^_535272
3-0 1^2^3^4^nil                   3-0 1^2^3^4^nil
3-1 ... ^ ...                     3-1 1^ ... ^ ...
3-2 1^ ... ^ ...                  3-2 1^2^ ... ^ ...
3-3 1^2^ ... ^ ...                3-3 1^2^3^ ... ^ ...
3-4 1^2^3^ ... ^ ...              3-4 1^2^3^4^nil
3-5 1^2^3^4^nil                   3-5 1^2^3^4^nil
4-0 [1,2,3,4]                     4-0 [1,2,3,4]
4-1 [...|...]                     4-1 [1,...]              Suggested: [1|...]
4-2 [1,2|...]                     4-2 [1,2,...]
4-3 [1,2,3|...]                   4-3 [1,2,3,...]
4-4 [1,2,3,4]                     4-4 [1,2,3,4]
4-5 [1,2,3,4]                     4-5 [1,2,3,4]
5-0 [_1581,_1613,_1645,_1677]     5-0 [_535278,_535287,_535291,_535293]
5-1 [_1581|...]                   5-1 [_535278,...]
5-2 [_1581,_1613|...]             5-2 [_535278,_535287,...]
5-3 [_1581,_1613,_1645|...]       5-3 [_535278,_535287,_535291,...]
5-4 [_1581,_1613,_1645,_1677]     5-4 [_535278,_535287,_535291,_535293]
5-5 [_1581,_1613,_1645,_1677]     5-5 [_535278,_535287,_535291,_535293]

UWN avatar Jul 11 '23 06:07 UWN

Here is probably the smallest incorrect term:

?- write_term([_,_|_],[max_depth(1)]).
[_535624,...]   true, unexpected.

UWN avatar Jul 13 '23 11:07 UWN

Why do 2-1 and 3-1 differ in SICStus (they differ in whether the left operand is substituted by ...)? That makes absolutely no sense to me.

mthom avatar Jul 21 '23 20:07 mthom

What does a ... stand for? In an abbreviated term, it either stands for itself (should the program itself use this atom), or it stands for another non-variable term. Variables do not need to be abbreviated, they are short enough by themselves.

UWN avatar Jul 22 '23 05:07 UWN

?- write_term("ab", [max_depth(1)]).
[a,b]   true, unexpected.

triska avatar Sep 03 '23 07:09 triska