Functional implementation of anti-unification algorithm for multiple terms