string_list(+string, ?character_code_list)
string_list(?string, +character_code_list)

An atom name and a list of integers are unified. If the first argument is an atom then it is decomposed into a list of integers and that list is unified with the second argument. The integers are the ASCII values of the characters of the atom

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

Examples
string_list("string", X)  X=[115, 116, 114, 105, 110, 103]
string_list("string", [115, 116 | Y]). X=[114, 105, 110, 103]
string_list(X, [115, 116]). X="st"
string_list("string", [115, Y]). fails

 

Exceptions
both arguments are empty variables an instantiation_error exception is thrown

 

 

info@trinc-prolog.com