Write a prolog program that defines the predicate groundTerm(Term) which tests whether or not Term is a ground term. Ground terms are those taht don't contain variables. Here are examples of how the predicate should behave. groundTerm(X). false. groundTerm(french(bic_mac,le_bic_mac)). true. groundTerm(french(whopper,X)). false. Also, the predicate should terminate execution immediately after producing its first (and only) solution.
The prolog program to check for the ground term is given as follow:
----------------------------------------code-----------------------------------------------------------
groundterm(Term) :-
nonvar(Term),
Term =.. [_ | X],
groundterm_in_list(X).
groundterm_in_list([H|T]) :-
groundterm(H),
groundterm_in_list(T).
groundterm_in_list([]).
------------------------------------------------------------------------------------------------
The prolog program above checks for the groundterm.
--------------------------------------Please Upvote--------------------------------------------------------------------------------
Get Answers For Free
Most questions answered within 1 hours.