:- module(format, [format_to_chars/4, format_to_chars/3, format_to_atom/3]).

:- use_module(library(charsio)).

format_to_chars(Format, Args, S0, S) :-
   format_to_chars(Format, Args, Chars),
   append(Chars, S, S0).

format_to_chars(Format, Args, Chars) :-
   with_output_to_chars(format(Format, Args), Chars).

format_to_atom(Format, Args, Atom) :-
   format_to_chars(Format, Args, Chars), atom_chars(Atom, Chars).
