7.3.3 List Processing

append(L1, L2, L3)

Succeed if L3 is the concatentation of L1 and L2

rel append(!list(T), !list(T), ?list(T)),
    append(?list(T), ?list(T), !list(T)),
    append(!list(??T), !list(??T), ?list(??T)),
    append(?list(??T), ?list(??T), !list(??T)),
    append(??list(T), ??list(T), ??list(T))

reverse(L1, L2)

Succeed if list L2 is the reverse of L1.

rel reverse(!list(T), ?list(T)),
    reverse(?list(T), !list(T)),
    reverse(!list(??T), ?list(??T)),
    reverse(?list(??T), !list(??T))

sort(L1, L2, Order)

Will match the second argument against the first argument sorted by the transitive order relation given as the third argument, without instantiating variables in the first argument. If the relation is asymmetric, duplicate terms will be removed.

rel sort(!list(!T), ?list(T), !rel(!T, !T)),
    sort(!list(??T), ?list(??T), !rel(??T, ??T))

member(X, L)

Succeed if X is in L.

rel member(?T, !list(T)),
    member(??T, ??list(T))

X in L

Succeed if X is in complete list of terms L.

It almost has the same uses as member except that it it must be given a complete list of possibly non-ground terms.

As its type indicates, in can also be used to access single character substrings of a string, a tuple and the ground elements of a set.

rel ?T in !list(T),
    ??T in !list(??T),
    ?T in !tuple(T),
    ??T in !tuple(??T),
    ?T in !set(T),
    ?string in !string

On This Site