Visual Prolog Program to find length of a list.
In this program the predicate length takes integer list and output a integer which is the length of list. Here the predicate length is called repeatedly or recursively until a last empty list is encountered and the 0 value is returned which is then continuously incremented to find the length.
%to find the length of the list
DOMAINS
int_list=Integer*
PREDICATES
length(int_list,integer)
CLAUSES
length([],0).
length([H|T],L):-
length(T,L1),L=L1+1.
GOAL
length([1,2,3,4,5,6],X).
output
Your blog is different from other blog and provide good information thanks for sharing. . .
ReplyDeleteregistered packers and movers lucknow.