atom_length(+atom, ?integer) [ISO]

Relate an atom and its number of characters.The first parameter must always be an instantiated atom, the length of the supplied atom is unified with the second parameter.

see also: atom_base64/2 atom_codes/2 atom_compress/2 atom_concat/3 atom_encrypt/3 atom_final_md5/1 atom_integers/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_length('peter', L). L=5 is the output
atom_length('', 0). succeeds with 'yes'

 

Exceptions  
Atom is a variable an instantiation_error exception is thrown
Atom is neither a variable nor an atom a type_error(atom, Atom) exception is thrown
Length is neither a variable nor an integer a type_error(integer, Length) exception is thrown
Length is an integer that is less than zero a domain_error(not_less_than_zero, Length) exception is thrown

 

 

info@trinc-prolog.com