Re: quite a simple problem

Daniel Diaz <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Message-ID <[email protected]>
Yury Luneff wote :
> You see, I've got something like this:
> | ?- read(Hello).
> Hello.
> 
> yes
> | ?- write(Hello).
> _16
> 
> This is not what I've expected to see and because of this my program
> doesn't work as it should. What do I have to do with this or
> everything's normal?

You have to look at the syntax of Prolog terms. I suppose you want to 
read/write the constant "Hello". In Prolog a constant must be quoted 
like this 'Hello'. However, for a easier use, a constant which begins 
with a lower case letter (a-z) and followed by letters, digits or _ does 
not need quotes. So 'hello' can be simply written as hello (without 
quotes) but 'Hello' cannot be written without quotes. Indeed, if the 
first character is an upper case letter (A-Z) then it is considered as 
the name of a variable (not a constant). So use :

| ?- read(X).
'Hello'.

X = 'Hello'

yes
| ?- write('Hello').
Hello

yes
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.