:- use_module(library(terms)).(can be autoloaded)
call(Goal4, SubTerm1, SubTerm2, StateIn, StateOut)for each subterm, including variables, in Term1. If this call fails, StateIn and StateOut are the same. This predicate may be used to map subterms in a term while collecting state about the mapped subterms. The foldsubterms/4 variant does not map the term.