# Prolog - List Append.

 home  Bib  Algorithms  Bioinfo  FP  Logic  MML  Prog.Lang and the  mmlist

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.

window on the wide world:
 The Darwin Awards V: Next Evolution

 Linux  Ubuntu free op. sys. OpenOffice free office suite, ver 3.4+ The GIMP ~ free photoshop Firefox web browser FlashBlock like it says!

 © 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, 29-Oct-2020 04:24:54 AEDT.