###Length 12
length(L,3).
length/2
is a built-in predicate of Prolog which is true if its first argument is a list of length its second argument. Here, we are setting the second argument as a ground integer, and the first as a variable. Thus, we get the following behavior:
?- length(L,3).
L = [_G1500, _G1503, _G1506].
That is, for that query to be true, L
must be a list of 3 elements; those elements are _G1500
, _G1503
and _G1506
which are variables (those names are internal variable names).
We can also run that predicate with both arguments as variables, and get the following very powerful behavior:
?- length(L,M).
L = [],
M = 0 ;
L = [_G1512],
M = 1 ;
L = [_G1512, _G1515],
M = 2 ;
L = [_G1512, _G1515, _G1518],
M = 3 ;
L = [_G1512, _G1515, _G1518, _G1521],
M = 4 ;
…