Prolog type checking
Prolog defines a group of built-in predicates for type testing purposes: var/1
, atom/1
, integer/1
, float/1
, atomic/1
, compound/1
, nonvar/1
, number/1
, all of them with quite a self-explanatory meaning if you know the data types of the language. For specific characters, you may exploit unification with that character, after checking that the element is not a free variable (otherwise unification is always successful).
You could try this code:
isList([_|_]).
isList([]).
Hope it helps.
To check if a variable is bound to a list, you can use is_list/1
.