Term2list

Description

Constructing a list corresponding to a term.

Source: The Art of Prolog

Download

Program source code: term2list.pl

Listing

/*
   univ(Term, List) :- List is a list containing the functor of Term followed 
		by the arguments of Term.
*/
     univ(Term, [F|Args]) :-
		functor(Term,F,N), args(0,N,Term,Args).
 
     args(I,N,Term,Arg,Args) :-
		I < N, I1 is I+1, arg(I1,Term,Arg), args(I1,N,Term,Args).
     args(N,N,Term,[]).
 
%  Program 9.5a   Constructing a list corresponding to a term

Comments

pl/prolog/pllib/term2list.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