char_atom(?Char, ?Atom)

char_atom/2 converts between character codes and atoms. Atom must be an atom or a variable. Char must be a character code or a variable. Character codes are integers in the range 1..255.

If either argument is instantiated, but Char is not a valid character code or Atom is not an atom, char_atom/2 fails silently.

If Char is a valid character code, Atom is unified with the atom whose name is [Char].

If Atom is an atom, and its name contains a single character, Char is unified with the code of that character.

char_atom(Char, Atom) is true when Char is a character code, Atom is an atom whose name contains exactly one character, and Code is the code of that character. If Atom's name has no characters, or more than one, this predicate is simply false. Error exceptions and efficiency aside, char_atom/2 could be defined as

     char_atom(Char, Atom) :-
             atom_chars(Atom, [Char]).