Did you know ... Search Documentation:
Pack prolog_library_collection -- prolog/term_ext.pl
PublicShow source

Extends the support for terms in the SWI-Prolog standard library.

 ascii_id(-Id:atom) is det
 ascii_id(+Term:term, -Id:atom) is det
Generates an Id for the given Prolog term. The Id is guarantee to only contain ASCII letter and digits to ensure that it can be used by many programs.

Prolog terms can contain many characters and can have arbitrary size. For these reasons, this predicate generates the Id based on the MD5 hash of a serialization of the given Prolog term.

MD5 hashes sometimes start with an ASCII digit, which is not supported in some languages/context (for example, the DOT language does not allow IDs to start with a digit). For this reason, an arbitrary ASCII letter is prefixed at the beginning of the Id.

 compound_name(+Term:compound, +Name:atom) is semidet
compound_name(+Term:compound, -Name:atom) is det
 number_of_variables(+Term:term, -NumberOfVariables:nonneg) is det
 replace_blobs(+Term1, -Term2) is det
Copy Term1 to Term2, replacing non-text blobs. This is required for error messages that may hold streams and other handles to non-readable objects.
 shared_vars(+Terms:list(term), -SharedVariables:ordset(var)) is det
 write_fact(@Term) is det
 write_term(@Term) is det
Alternative to write_canonical/[1,2] that lives up to the promise that "terms written with this predicate can always be read back".