Availability:built-in
- If Atom is instantiated, it will be translated into a list of character codes, which are unified with CodeList.
- If Atom is uninstantiated and CodeList is a list of character codes, then Atom will be unified with an atom constructed from this list.
?- atom_codes(hello, X). X = [104, 101, 108, 108, 111].
The‘listwards’call to atom_codes/2 can also be written (functionally) using backquotes instead:
?- Cs = `hello`. Cs = [104, 101, 108, 108, 111].
Backquoted strings can be mostly found in the body of DCG rules that process lists of character codes.
Note that this is the default interpretation for backquotes. It can be changed on a per-module basis by setting the value of the Prolog flag back_quotes.