PLOGHELP APPEND                              Robert Duncan, January 1988


    :- library(useful).

    ?- append(List1, List2, List3).


This goal succeeds whenever List3 is the concatenation of List1 and
List2.

The simplest and most frequent use of this predicate is to join two
lists into one. For example:

    ?- append([a, b, c], [d, e, f], List3).
    List3 = [a, b, c, d, e, f] ?
    yes

Conversely, it may be used to generate all those pairs of lists which
when joined are equal to some given list, as in:

    ?- append(List1, List2, [a, b, c]).
    List1 = []
    List2 = [a, b, c] ? ;

    List1 = [a]
    List2 = [b, c] ? ;

    List1 = [a, b]
    List2 = [c] ? ;

    List1 = [a, b, c]
    List2 = [] ? ;

    no

Prefix and suffix relations can also be constructed from append/3. The
rule

    prefix(P, S) :- append(P, X, S).

can be read as: "P is a prefix of S if there is some X for which P
appended to X is equal to S". Thus:

    ?- prefix("cat", "catalogue").
    yes

    ?- prefix("cat", "calibrate").
    no.


append/3 is a library predicate defined in LIBRARY USEFUL. Its
definition is:

    append([], List, List).
    append([X|List1], List2, [X|List3]) :-
        append(List1, List2, List3).


-- RELATED DOCUMENTATION ----------------------------------------------

PLOGHELP * LIBRARY
    How to use the library mechanism.

PLOGHELP * USEFUL
    A library of useful predicates.

--- C.all/plog/help/append ---------------------------------------------
--- Copyright University of Sussex 1988. All rights reserved. ----------
