Subject: Re: [SWIPL]

From: Jan Wielemaker <[email-masked]>
Date: Thu, 8 Feb 2001 10:26:05 +0100

>  >How do you explain the confusion between a number N and a list of a number
>  >[N]?
>  > For instance, "?- [2]<3." succeeds and "?- X is [2]+3." leads to X=5.
>  >Jean-louis Bouquard
> 
> A set containing the element n is different from the element n. In Prolog, 
> the list containing a number n is denoted [n]. [n] is not a  number; it is 
> a list containing a number. Similarly, [] is different from  [[]]. The 
> first is the empty list and the second is the one element list which has 
> the empty list as its element.

All true, but the confusion might also be that [X] is treated as X by
arithmetic evaluation.  This is to allow using the following

is_ascii_lower_letter(X) :-
	X >= "a",
	X =< "z".

As "a" stands for [<code of 'a'>] this works nicely.  Alternatively you
can write

is_ascii_lower_letter(X) :-
	X >= 0'a,
	X =< 0'z.

I think this is nicer, though the 0'x syntax is a bit awkward for
syntax sensitive editors.

	--- Jan