Ground term

Description

Testing if a term is ground.

Source: The Art of Prolog

Download

Program source code: ground_term.pl

Listing

/* 
     myground(Term) :- Term is a ground term.
*/
     myground(Term) :- 
        nonvar(Term),
	constant(Term).
     myground(Term) :- 
        nonvar(Term),
	compound(Term),
	functor(Term,F,N),
	myground(N,Term).
 
     myground(N,Term) :-
        N > 0,
	arg(N,Term,Arg),
	myground(Arg),
	N1 is N-1,
	myground(N1,Term).
     myground(0,Term).
 
%  Program 10.4   Testing if a term is ground

Comments

pl/prolog/pllib/ground_term.txt · ostatnio zmienione: 2017/07/17 08:08 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0