to_prolog(+term)

This string predicate converts an expression to a valid Prolog string. A valid Prolog string means that the string can be used as input for the Prolog compiler again. The predicate can only be used in a string expression. The to_prolog/2 predicate checks if it is necessary to add single quotes to atoms and it also checks for single quote characters inside atoms.

Use to_string/2 if the result string must not be a valid Prolog string.

see also: &/2 delete/3 expand_sq/1insert/3 is/2 replace/3 substring/3 string_list/2 to_lower/1 to_string/2 to_upper/1  trim/1 triml/1 trimr/1 working with strings

Examples
A='te''st', X is_string to_prolog(A), write(X). variable X is unified with the 'te''st'
A='te''st', X is_string to_string(A), write(X). variable X is unified with the te'st

 

Exceptions
The parameter is an empty variable a type_error(evaluable, PredicateIndicator) exception is thrown

 

 

info@trinc-prolog.com