Finite lists
A list literal is written with square brackets and commas:[H | T] — H binds to the first element
(the head) and T binds to the rest (the tail):
| is a fixed prefix of elements; everything after it is the
remaining list. You can bind several leading elements at once, as in [A, B | Rest].
Declare a list-valued column with the list<T> type, where T is any scalar type.
List types nest, so list<list<u32>> is a column of lists of lists:
Lists in XLOG are finite and interned. At compile time every list literal and cons
structure is registered to a dense integer ID, so a
list<T> column joins and compares
as fast as any integer column. There are no unbounded or cyclic lists — a list you can
write down is a list the compiler can intern, and nothing else is representable.Meta-predicates
Only one meta-predicate,=.. (read “univ”), is part of the grammar. It relates a
compound term to a list of its functor and arguments — the same role it plays in
Prolog. Every other meta-predicate is an ordinary atom recognized by its predicate
name during compilation, not a special syntactic form.
findall/3
findall/3 collects every value of a template into a list:
Y for which edge(1, Y) holds and binds Xs to the resulting list.
maplist and functor/3
maplist applies a predicate across the elements of a list, and functor/3 relates a
compound term to its functor name and arity. Both are recognized by name and expanded
during meta-normalization.
ground/1, var/1, nonvar/1 — folded at compile time
ground/1, var/1, and nonvar/1 look like runtime tests, but they are folded at
compile time. At the program point where each appears, the compiler already knows
whether the term is bound or ground, so the call resolves to either success (it vanishes)
or a fail atom that prunes the rule. They never execute as runtime checks — they are a
compile-time decision about the shape of your program, not a query against your data.
No runtime database
XLOG evaluates a program to a fixpoint; it has no mutable runtime database. The dynamic-database predicates are therefore rejected with a typed error:Modules
Split a program across files, import selectively, and control visibility with
private.