[Cst-1b] Mistake in Prolog Notes?
M.Y.W.Y.B.
mywyb2@hermes.cam.ac.uk
Wed, 17 May 2000 22:00:22 +0100
--On Mittwoch, 17. Mai 2000, 21:37 +0100 "Nic Infante"
<ngli2@thor.cam.ac.uk> wrote:
> I think it's not a proper list as the first term [a,b] is a list and
> the second c (an atom since in lower case) is not. notation, the second
> term . In the dot notation, (c,[]) would have to be a list of lists, which
> it can't be. [[a,b],C] could be a list since C is a variable and could be
> instantiated to a list. Although I've just noticed that he's got
> [[the,cat],sat] as an example of a list so I'm not sure.
In Prolog list elements needn't have the same type (unlike ML).
So
[ 3.14, apple, [1], (a,b) ]
is a proper list.
Therefore if you've got the term .(X,Y), the necessary and sufficient
condition for it being a proper list is that Y has to be a proper list of
length >= 0.
In the example, Y corresponds to .(c,[]) which clearly is a list.
Moritz