atom_codes(+atom, ?character_code_list) [ISO]
atom_codes(-atom, +character_code_list) [ISO]

An atom name and a list of character codes are unified. If the first argument is an atom then it is decomposed into a list of character codes and that list is unified with the second argument.

If the left argument is a variable then the predicate tries to create an atom from the list of character codes of the right argument and unify the new atom it created with the left argument.

see also: atom_base64/2 atom_chars/2 atom_compress/2 atom_concat/3 atom_encrypt/3 atom_final_md5/1 atom_length/2 atom_reset_md5/0 atom_update_md5/1 char_code/2 number_chars/2 number_codes/2 number_integers/2 sub_atom/5

Example
atom_codes('peter', L). L=[0'p, 0'e, 0't, 0'e, 0'r] is the output
atom_codes('pet', [0'p|T]). after unification the variable T has the value [0'e, 0't]
atom_codes(A, [0'p, 0'e]). A is unified with the value 'pe'

 

Exceptions  
Atom is neither a variable nor an atom a type_error(atom, Atom) exception is thrown
Atom is a variable and List is a variable or a partial List or a list with a variable as element an instantiation_error exception is thrown
Atom is a variable and List is neither a variable nor a partial list nor a list a type_error(list, List) exception is thrown
Atom is a variable and an element E of the list is neither a variable nor a character code a representation_error(character_code) exception is thrown

 

 

info@trinc-prolog.com