An atom name and a list of one-character atoms are related. If the first argument is an atom then it is decomposed into a list of characters and that list is unified with the second argument.
If the first argument is a variable then this predicate tries to create an atom from the list of characters of the right argument and unify the new atom it created with the left argument.
see also: atom_codes/2 atom_concat/3 atom_length/2 char_code/2 number_chars/2 number_codes/2 sub_atom/5
| Example | |
| atom_chars('peter', L). | L=['p', 'e', 't', 'e', 'r'] is the output |
| atom_chars('pet', [p|T]). | after unification the variable T has the value ['e', 't'] |
| atom_chars(A, [p, 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 one-char atom | a type_error(character, E) exception is thrown |