Spis treści

List2term

Description

Download

Listing

/*
univ(Term, List) :-
The functor of Term is the first element of the list List,
and its arguments are the rest of List's elements.
*/univ(Term,[F|Args]):-
length(Args,N),functor(Term,F,N), args(Args,Term,1).
args([Arg|Args],Term,N):-arg(N,Term,Arg), N1 is N+1, args(Args,Term,N1).
args([],Term,N)./*
mylength(Xs,N) :- N is the mylength of the list Xs.
*/
mylength([X|Xs],N):- mylength(Xs,N1), N is N1+1.
mylength([],0).% Program 9.5b Constructing a term corresponding to a list