Quintus Prolog Reference Manual

version 6, April 1986. This manual corresponds to:
Quintus Prolog Release 1.5 (Sun)
Quintus Prolog Release 1.5 (VAX Unix 4.2 BSD)
Quintus Prolog Release 1.5 (VAX/VMS)
Quintus Prolog Release 1.5 (Apollo DOMAIN/IX)

...

18: MISCELLANEOUS BUILT-IN PREDICATES

p.121..122: ...

18-3: length(?L,?N)

If L is instantiated to a list of definite length, this length is unified with N. For example,
| ?- length([a,B,1,f(x)],N).

N = 4
Otherwise, if L is uninstantiated and N is a non-negative integer, then L is bound to a list of N distinct variables. For example,
| ?- length(L,2).

L = [_117,_119]
If the arguments to length satisfy neither of these conditions, the call simply fails. For example
| ?- length([a|X],L).

no
...
Quintus Prolog Release 3.3

l-2-14: List Processing

l-3: Built-in Predicates

...

length/2

Synopsis:
length(-List, +Integer) length(*List, *Integer)
Integer is the length of List. If List is instantiated to a proper list, the predicate is determinate, also when Integer is var.
Arguments:
List
<list> a list
Integer
<integer> non-negative integer
Description:
Backtracking:
If both List and Integer are variables, the system will backtrack, generating lists of increasing length whose elements are anonymous variables.
Exceptions:
Examples:
| ?- length([1,2], 2).
  yes

| ?- length([1,2], 0).
  no

| ?- length([1,2], X).
  X = 2 ;
  no
...
Same in most recent version 3.5