The Depth argument specifies the nesting depth of the term up to which the term's components are taken into account for the computation of the hash value. More deeply nested parts of the term will be ignored. If the term contains uninstantiated parts in the portion up to Depth, no reliable hash value can be computed and the predicate succeeds, leaving Hash uninstantiated. If Depth is set to -1, the whole depth of the term will be used for computing the hash value. If Depth is set to 0, the hash value will be 0. The main functor of a term is taken to be at depth 1, its arguments at depth 2 etc.
Success: [eclipse 1]: term_hash(hello, 1, 100, H). H = 4 yes. [eclipse 2]: term_hash(world, 1, 100, H). H = 84 yes. [eclipse 15]: term_hash(foo(bar,3,4.5), -1, 100, H). H = 40 yes. [eclipse 15]: term_hash(foo(bar,3,4.5), 1, 100, H). H = 72 yes. [eclipse 18]: term_hash(foo(X,3,4.5), 1, 100, H). X = X H = 72 yes. [eclipse 19]: term_hash(foo(X,3,4.5), 2, 100, H). X = X H = H yes.