Skip to content

Commit

Permalink
ENHANCED: format_//2, format/[2,3], portray_clause/1 are now determin…
Browse files Browse the repository at this point in the history
…istic.

This works as soon as mthom#732 is merged, since then maplist/N and foldl/N
are deterministic in the required cases.

This also resolves the extra choicepoint of time/1 (see mthom#378).
  • Loading branch information
triska committed Dec 19, 2020
1 parent b9a53e4 commit 3720e0f
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/lib/format.pl
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
consume whitespace in the sense of format strings.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

cells([], Args, Tab, Es, _) -->
cells([], Args, Tab, Es, _) --> !,
( { Args == [] } -> cell(Tab, Tab, Es)
; { domain_error(empty_list, Args, format_//2) }
).
Expand Down Expand Up @@ -404,32 +404,28 @@
?- phrase(format_("hello~n~tthere~6|", []), Ls).
?- format("~ta~t~4|", []).
a true
; false.
a true.
?- format("~ta~tb~tc~10|", []).
a b c true
; false.
a b c true.
?- format("~tabc~3|", []).
?- format("~ta~t~4|", []).
?- format("~ta~t~tb~tc~20|", []).
a b c true
; false.
a b c true.
?- format("~2f~n", [3]).
3.00
true
true.
?- format("~20f", [0.1]).
0.10000000000000000000 true % this should use higher accuracy!
; false.
0.10000000000000000000 true.
?- X is atan(2), format("~7f~n", [X]).
1.1071487
X = 1.1071487177940906
X = 1.1071487177940906.
?- format("~`at~50|~n", []).
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Expand All @@ -438,10 +434,10 @@
?- format("~t~N", []).
?- format("~q", [.]).
'.' true
'.' true.
?- format("~12r", [300]).
210 true
210 true.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down Expand Up @@ -537,7 +533,7 @@
b,
c,
d.
true
true.
?- portray_clause([a,b,c,d]).
Expand Down

0 comments on commit 3720e0f

Please sign in to comment.