scryer-prolog
scryer-prolog copied to clipboard
Write option max_depth/1
See GNU: https://github.com/didoudiaz/gprolog/issues/56
Related: https://github.com/mthom/scryer-prolog/issues/1803
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]
Here is probably the smallest incorrect term:
?- write_term([_,_|_],[max_depth(1)]).
[_535624,...] true, unexpected.
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.
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.
?- write_term("ab", [max_depth(1)]).
[a,b] true, unexpected.