atom_concat(?atom, ?atom, +atom) [ISO]
atom_concat(+atom, +atom, -atom) [ISO]

Atom concatenation and splitting, if the third argument is specified then that atom is split and unified with the first two arguments, if the first two arguments are both variables then all possible concatenations that result in same the atom are produced. The third example below demonstrates that.

If the first two arguments are not variables then both these atoms are concatenated and unified with the third argument. The first example demonstrates this.

see also: atom_base64/2 atom_codes/2 atom_compress/2 atom_encrypt/3 atom_final_md5/1 atom_integers/2 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_concat('hi', ' john', L). the variable L is unified with the atom 'hi john'
atom_concat(A, ' john', 'hi john'). after unification the variable A has the value 'hi'
atom_concat(A, B, 'hi john'). All the solutions generated are:
A=
B=hi john

A=h
B=i john

A=hi
B= john

A=hi
B=john

A=hi j
B=ohn

A=hi jo
B=hn

A=hi joh
B=n

A=hi john
B=

 

Exceptions  
The first and second parameters are variables an instantiation_error exception is thrown
The second and third parameters are variables an instantiation_error exception is thrown
The first Atom parameter is neither a variable nor an atom a type_error(atom, Atom1) exception is thrown
The second Atom parameter is neither a variable nor an atom a type_error(atom, Atom2) exception is thrown
The third Atom parameter is neither a variable nor an atom a type_error(atom, Atom3) exception is thrown

 

 

info@trinc-prolog.com