3 ms·
Prolog is a logic programming language. It's not object-oriented, so it doesn't have objects or methods. If you want to know the length of a list you can use t
by YeGoblynQueenne 10y ago
Prolog is a logic programming language. It's not object-oriented, so it doesn't have objects or methods.
If you want to know the length of a list you can use the predicate length/2:
?- length([a,b,c,d], N).
N = 4.
The example above just shows you how length/2 works (albeit with some CLP operators that are not typical).
Edit: also, lists are not a "collection type" or any type at all. They're predicates, like everything else in the language. See my comment below - the easiest way to think of them is as patterns (just like in regexes, only Turing complete).