Succeeds if Structs is a list of length Length, whose elements all have the same functor Name/Arity. Operationally, this can be used to either generate a list with of this form, or to check whether an existing list corresponds to it.
This is (modulo nondeterminism) similar to
( foreach(S,Structs), count(_,1,Length), param(Name,Arity) do functor(S,Name,Arity) )
Note that (like in the underlying functor/3 predicate), if Arity is zero, Name can be any atomic term (including number or string).
% fill a list with structure skeletons ?- terms_functor(Ss, 3, f, 2). Ss = [f(_275,_276), f(_278,_279), f(_281,_282)] Yes (0.00s cpu) % check whether all elements have same toplevel functor ?- terms_functor([f(a),f(b)], L, F, A). L = 2 F = f A = 1 Yes (0.00s cpu) % complete a list acccording to a prototype ?- terms_functor([f(a)|Ss], 4, _, _). Ss = [f(_190), f(_194), f(_198)] Yes (0.00s cpu) % fill a list with an atomic term (arity 0) ?- terms_functor(Ss, 3, 99, 0). Ss = [99, 99, 99] Yes (0.00s cpu)