You are currently viewing Program to append the list in prolog.

Program to append the list in prolog.

In previous article we have seen how to find the population density of the country. In this we will discuss about how to append the list.

The following program appends a list B to another list A. The collective list is stored in list C. The base condition is “append ([], list B, list B)”. The program observes backtracking after the base condition is achieved.

 

PROGRAM:

append[x|y],z,[x,w]:-append(y,z,w),append([],x,x).

 

OUTPUT:

 

Dinesh Kumar Bansal

Dinesh Kumar Bansal is an Indian Software Developer, who is working on ASP.Net, MS-SQL, SAP-ABAP technologies from last one year. His Basic Principle of developing software is, “You have to clear about, what do you want to do, how can it be done”. He always says that development can be done with a cool & fresh mind.

Leave a Reply