  We study the arity gap of functions of several variables defined on an
arbitrary set A and valued in another set B. The arity gap of such a function
is the minimum decrease in the number of essential variables when variables are
identified. We establish a complete classification of functions according to
their arity gap, extending existing results for finite functions. This
classification is refined when the codomain B has a group structure, by
providing unique decompositions into sums of functions of a prescribed form. As
an application of the unique decompositions, in the case of finite sets we
count, for each n and p, the number of n-ary functions that depend on all of
their variables and have arity gap p.
