Markus Triska
d72cb74ffa
mention phrase_to_file/3 which is being prepared in #1100
2021-11-17 21:33:15 +01:00
Markus Triska
3c988d555f
'f' --> f
2021-11-17 21:20:40 +01:00
Markus Triska
5981a65cc2
better layout
2021-11-17 21:20:40 +01:00
Markus Triska
9900762747
use newly available seq//1 from library(dcgs)
...
I am using seq(Ls) instead of plain Ls so that DCGs can be debugged
declaratively, by generalizing away nonterminals in rules.
2021-11-17 21:20:40 +01:00
Markus Triska
bd75e9c184
more elegant solution for parsing numeric arguments, using a DCG
2021-11-16 18:25:35 +01:00
Markus Triska
23df16ecf9
mention the format("~s", [Ls]) pattern and new library(pio) predicates
2021-11-16 18:20:58 +01:00
Mark Thom
75b01d5021
Merge pull request #1082 from pmoura/fix_format_predicates_missing_numbervars_option_on_w_and_q_formats
...
Fix the format/2-3 predicates missing the numbervars(true) option in the ~w and ~q formats
2021-11-13 00:05:26 -05:00
Paulo Moura
7ea20d9ce9
Fix the format/2-3 predicates missing the numbervars(true) option in the ~w and ~q formats
2021-11-08 22:00:02 +00:00
Markus Triska
a0a01b8ba7
ADDED: library(format): DCG nonterminal portray_clause_//1, in analogy to format_//2.
2021-11-07 17:47:05 +01:00
Markus Triska
e32215e19a
express format/3 and portray_clause/2 in terms of phrase_to_stream/2
2021-11-07 17:47:05 +01:00
Markus Triska
f668640e3d
move error handling to Prolog by using the new '$first_non_octet'/2
2021-11-04 18:35:22 +01:00
Markus Triska
9e13f18463
ENHANCED: Domain error non_empty_list for empty arguments, addressing #1024 .
...
Example:
?- format("~d", []).
%@ caught: error(domain_error(non_empty_list,[]),format_//2)
2021-08-15 12:29:28 +02:00
Markus Triska
9d3f3eb013
ENHANCED: format_string domain error for invalid radix in format string
...
This addresses #1024 .
Example:
?- format("hello ~0r!", [12]).
%@ caught: error(domain_error(format_string,"~0r"),format_//2)
2021-08-14 20:04:07 +02:00
Markus Triska
78c2f19e72
ENHANCED: If N is omitted in ~Nr or ~NR, it defaults to 8.
...
This is for compatibility with Quintus, SICStus and GNU Prolog,
addressing #1024 .
Example:
?- format("~r", [10]).
%@ 12 true.
2021-08-14 13:48:21 +02:00
Markus Triska
842176a595
is is --> is
2021-03-05 18:36:00 +01:00
Markus Triska
d92951ba5b
ENHANCED: more readable indentation of nested disjunctions
...
Example:
?- portray_clause((h :- a ; b ; c)).
h :-
( a
; b
; c
).
true.
2021-03-04 21:40:24 +01:00
Markus Triska
c5749cbbb1
remove unnecessary argument
2021-03-04 21:40:24 +01:00
Markus Triska
6477d21e24
ENHANCED: more readable indentation of nested ( If -> Then ; Else ) constructs
...
Example:
?- portray_clause((h :- ( a -> b ; c -> d ; e, f))).
h :-
( a ->
b
; c ->
d
; e,
f
).
true.
2021-03-03 22:34:09 +01:00
Markus Triska
1bdfc5a1a4
~| now incorporates the number of characters described so far
...
Therefore, subsequent uses of ~N| now yield the specified column,
instead of potentially overshooting.
Example:
?- format("hello~|~t~8|!", []).
hello ! true.
Such cases are probably rather uncommon: Relative positioning with ~N+
is more likely to be used in such cases, and that worked as intended
also previously as it does now:
?- format("hello~|~t~3+!", []).
hello ! true.
In fact, if absolute positions are used, then ~| can be omitted entirely:
?- format("hello~t~8|!", []).
hello ! true.
2021-02-09 20:55:46 +01:00
Markus Triska
27a52ef56a
reflect improved determinism thanks to the improvements by @notoria
2020-12-23 00:05:29 +01:00
Markus Triska
4efbc20a4f
ENHANCED: format_//2, format/[2,3], portray_clause/1 are now deterministic.
...
This works as soon as #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 #378 ).
Many thanks to @notoria for implementing better indexing in #732 ,
which allowed me to find this opportunity for improvement!
2020-12-19 18:18:14 +01:00
Markus Triska
5f3ab823fd
FIXED: format_//2: Keep different variables distinct.
...
Example:
?- phrase(format_("~w~w", [_,_]), Ls).
%@ Ls = "AB"
%@ ; false.
2020-09-05 09:58:49 +02:00
Markus Triska
dcc4b91b35
ENHANCED: flush output for impure I/O (format/[2,3], portray_clause/1 etc.)
...
Without this, we do not get a (timely) prompt in cases like:
?- format("press a key: ", []), get_single_char(C).
whereas for example write/1 already works in such cases:
?- write('press a key: '), get_single_char(C).
press a key:
2020-07-25 09:49:02 +02:00
Markus Triska
8958ea036e
ENHANCED: much faster format/3 for text streams
...
This is now also used by format/2 to emit output on the terminal,
and significantly speeds up toplevel output of long strings.
2020-06-16 21:13:03 +02:00
Markus Triska
10a0f708b9
use format/3 to benefit from efficiency improvements
2020-06-14 10:51:24 +02:00
Markus Triska
409d3c168d
ENHANCED: faster format/3 when writing to binary streams
...
This is also more secure, since it does not change the atom table
and therefore leaves little trace of what was processed.
2020-06-14 10:43:25 +02:00
Markus Triska
44ebd894d5
ADDED: portray_clause/2, writing to a specified stream.
2020-06-13 16:45:47 +02:00
Mark Thom
33325f1574
remove vestigial prolog/ directory ( #444 )
2020-06-12 18:26:38 -06:00