# Prolog - List Append.

 home1 home2  Bib  Algorithms  Bioinfo  FP  Logic  MML  Prog.Lang and the  Book

Logic
Prolog
Introduction
Examples

The Append program can be used to append two lists:

 ```append(c(H,T), B, c(H,TB)) <= append(T, B, TB). append(nil, B, B). ? append( c(1, c(2, nil)), c(3, c(4, nil)), X). {\fB Append run Forwards. \fP} ```
 append(c(H,T), B, c(H,TB)) <= append(T, B, TB). append(nil, B, B). ? append( c(1, c(2, nil)), c(3, c(4, nil)), X). {\fB Append run Forwards. \fP}

The same program can also be run "backwards" to take a list apart:

 ```append(c(H,T), B, c(H,TB)) <= append(T, B, TB). append(nil, B, B). ? append( X, Y, c(1, c(2, c(3, nil))) ). {\fB Append run Backwards. \fP} ```
 append(c(H,T), B, c(H,TB)) <= append(T, B, TB). append(nil, B, B). ? append( X, Y, c(1, c(2, c(3, nil))) ). {\fB Append run Backwards. \fP}

In this case there are, in general, multiple solutions.

 Coding Ockham's Razor, L. Allison, Springer A Practical Introduction to Denotational Semantics, L. Allison, CUP

 Linux  Ubuntu free op. sys. OpenOffice free office suite The GIMP ~ free photoshop Firefox web browser

 © L. Allison   http://www.allisons.org/ll/   (or as otherwise indicated), Faculty of Information Technology (Clayton), Monash University, Australia 3800 (6/'05 was School of Computer Science and Software Engineering, Fac. Info. Tech., Monash University, was Department of Computer Science, Fac. Comp. & Info. Tech., '89 was Department of Computer Science, Fac. Sci., '68-'71 was Department of Information Science, Fac. Sci.) Created with "vi (Linux + Solaris)",  charset=iso-8859-1,  fetched Thursday, 25-Jul-2024 05:26:11 AEST.