% Circular List Example / Kota Nara, Ueda Lab.
% A "same_length" graph is a pair of partial lists of the same length.
% "XH = [1, 2 | XT], YH = [a, b | YT]" is a "same_length" graph for example.
typedef same_length(XT, XH, YT, YH) {
XH = XT, YH = YT.
'.'(X, XS, XH), '.'(Y, YS, YH) :- ground(X), ground(Y), same_length(XT, XS, YT, YS).
}
% If a circular list consists of two partial lists of the same length,
% divide it into two circular lists.
YT = [X | $x[XT]], XT = [Y | $y[YT]] :-
same_length($x, $y) | '.'(X, $x[XX], XX), '.'(Y, $y[YY], YY).