|
From: | Daniel Diaz |
Subject: | Re: quite a simple problem |
Date: | Sat, 10 Mar 2007 10:24:31 +0100 |
User-agent: | Thunderbird 1.5.0.10 (Windows/20070221) |
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
[Prev in Thread] | Current Thread | [Next in Thread] |