- format_predicate(+Char, +Head)
- If a sequence
~c(tilde, followed by some character) is found, the format/3 and friends first check whether the user has defined a predicate to handle the format. If not, the built-in formatting rules described above are used. Char is either a character code or a one-character atom, specifying the letter to be (re)defined. Head is a term, whose name and arity are used to determine the predicate to call for the redefined formatting character. The first argument to the predicate is the numeric argument of the format command, or the atom
defaultif no argument is specified. The remaining arguments are filled from the argument list. The example below defines
~Tto print a timestamp in ISO8601 format (see format_time/3). The subsequent block illustrates a possible call.
:- format_predicate('T', format_time(_Arg,_Time)). format_time(_Arg, Stamp) :- must_be(number, Stamp), format_time(current_output, '%FT%T%z', Stamp).
?- get_time(Now), format('Now, it is ~T~n', [Now]). Now, it is 2012-06-04T19:02:01+0200 Now = 1338829321.6620328.
- current_format_predicate(?Code, ?:Head)
- True when
Code is handled by the user-defined predicate specified by Head.