6.9 Lists

Introduction

  • A list is a sequence of term-values.

  • The values can be any kind of Prolog+CG data, except variables.

  • The values are separated by commas, and surrounded by parentheses:

    (data1, data2, data3, ..., dataN)

Example

For example, the the superTypes primitive returns a list of supertypes.

Consider the following type-hierarchy:

// Type hierarchy
Entity > Physical, Abstract.
Physical > Animate, Inanimate.
Animate > Animal, Human.
Human > Man, Woman.
Abstract > Point, Line, Circle.

If we now ask the following query:

?-superTypes(Woman, L).

we get the following answer:

{L = (Human, Animate, Physical, Entity)}

Summary

Thus a list is a sequence of one or more Prolog+CG data values, separated by commas and surrounded by parentheses.


PrevLite: 6.8 Queries
NextLite: 7 Formalizing texts

Prev: 6.8 Queries
Up: 6 Prolog for CG users
Next: 7 Formalizing texts