In LL, the following data types
are supported:
Symbols, numbers, strings, and lists work just like their COMMON LISP counterparts.
Because LL has to handle all data types that can be found on
the WAM stack
and heap
, PROLOG
structures had to be added.
They are quite similar to (1-dimensional) COMMON LISP
arrays in that
they allow efficient random access to all of their elements in contrast
to LISP/PROLOG lists which require linear access by applying a cdr
operation repeatedly.
In LL, structures are enclosed in square brackets and use LISP's Cambridge Polish prefix notation:
LL structures evaluate to themselves, thus quoting is not necessary but - as with numbers and strings - allowed.
In analogy to constructing lists with list or cons,
LL structures can be built up with struct (
denotes evaluation; expr
= expr
is equivalent
to expr
expr
):
(struct 'f 'a 'b 'c)
[f a b c]
(struct 'f 'a (struct 'g 'b 'c))
[f a [g b c]]
Using struct is the only way to construct a structure which contains variables. The RELFUN/REL goal
X is a, Y is f[X,b] Y = f[a, b]
has, in LL, to be expressed as:
(let ((x 'a)) (struct 'f x 'b)) [f a b]
LL - just like COMMON LISP - does not support pattern matching
or
unification
.
Selecting the constituents of a structure has to be done with the following
functions: