projog

3.50. atom_concat(X, Y, Z) - concatenates atom names.

atom_concat(X, Y, Z) succeeds if the name of atom Z matches the concatenation of the names of atoms X and Y.

Examples

Examples of when all three terms are atoms:

?- atom_concat(abc, def, abcdef).

yes

?- atom_concat(a, bcdef, abcdef).

yes

?- atom_concat(abcde, f, abcdef).

yes

?- atom_concat(abcdef, '', abcdef).

yes

?- atom_concat('', abcdef, abcdef).

yes

?- atom_concat('', '', '').

yes

?- atom_concat(ab, def, abcdef).

no

?- atom_concat(abc, ef, abcdef).

no

Examples of when first term is a variable:

?- atom_concat(abc, X, abcdef).
X = def

yes

?- atom_concat(abcde, X, abcdef).
X = f

yes

?- atom_concat(a, X, abcdef).
X = bcdef

yes

?- atom_concat('', X, abcdef).
X = abcdef

yes

?- atom_concat(abcdef, X, abcdef).
X =

yes

Examples of when second term is a variable:

?- atom_concat(X, def, abcdef).
X = abc

yes

?- atom_concat(X, f, abcdef).
X = abcde

yes

?- atom_concat(X, bcdef, abcdef).
X = a

yes

?- atom_concat(X, abcdef, abcdef).
X =

yes

?- atom_concat(X, '', abcdef).
X = abcdef

yes

Examples of when third term is a variable:

?- atom_concat(abc, def, X).
X = abcdef

yes

?- atom_concat(a, bcdef, X).
X = abcdef

yes

?- atom_concat(abcde, f, X).
X = abcdef

yes

?- atom_concat(abcdef, '', X).
X = abcdef

yes

?- atom_concat('', abcdef, X).
X = abcdef

yes

?- atom_concat('', '', X).
X =

yes

Examples of when first and second terms are variables:

?- atom_concat(X, Y, abcdef).
X =
Y = abcdef

yes;
X = a
Y = bcdef

yes;
X = ab
Y = cdef

yes;
X = abc
Y = def

yes;
X = abcd
Y = ef

yes;
X = abcde
Y = f

yes;
X = abcdef
Y =

yes

?- atom_concat(X, Y, a).
X =
Y = a

yes;
X = a
Y =

yes

?- atom_concat(X, Y, '').
X =
Y =

yes

Examples when combination of term types cause failure:

?- atom_concat(X, Y, Z).

Expected an atom but got: VARIABLE with value: Z

?- atom_concat('', Y, Z).

Expected an atom but got: VARIABLE with value: Z

?- atom_concat(X, '', Z).

Expected an atom but got: VARIABLE with value: Z

?- atom_concat(a, b, c).

no

?- atom_concat(a, '', '').

no

?- atom_concat('', b, '').

no

?- atom_concat('', '', c).

no