|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
strings and atoms with JPLHello,
I am wondering how can strings be used with JPL, and more generally, what is the link between atoms and strings. What I think is : strings are atoms with " ' " before and after. In JPL, there seems to be no distinction between a string and a "classical" atom. Are things like that ? Am I missing something ? I am asking this because I am wondering if strings in JPL should be treated differently than atoms or not, more specifically, should I think that any string (used in the context of JPl of course, in a term for example) *is* an atom ? Or is there a difference that make strings to be treated differently than atoms ? Thanks you for your help :) Victor |
|
|
Re: strings and atoms with JPLVictor NOEL wrote:
> Hello, > > I am wondering how can strings be used with JPL, and more > generally, what is the link between atoms and strings. > > What I think is : > strings are atoms with " ' " before and after. Then you are thinking of "quoted atoms", which are atoms whose names are quoted within a Prolog source text, perhaps because they would otherwise be misinterpreted or illegal: 2+2 == +(2,2) but '2+2' denotes an atom whose name has three characters. > In JPL, there seems to be no distinction between a > string and a "classical" atom. Nor is there in Prolog (except in input, output and source syntax). > Are things like that ? Am I missing something ? > > I am asking this because I am wondering if strings in JPL should > be treated differently than atoms or not, more specifically, > should I think that any string (used in the context of JPl of > course, in a term for example) *is* an atom ? Or is there a > difference that make strings to be treated differently than atoms ? JPL's jpl.Term class and its subclasses provide an alternative concrete syntax for Prolog, in which atom names such as 2+2 do not need to be quoted as above, hence new jpl.Atom("2+2") creates an atom identical to that denoted, in Prolog source, by '2+2'. I trust the need for double quotes is understood ;-| Of course, if you use JPL's convenience methods to create terms from Prolog source fragments, then you'll still need to quote such atoms, e.g. jpl.Query.oneSolution("assert(is_an_atom('2+2'))") > Thanks you for your help :) > > Victor regards - Paul Singleton ------------ For further info, please visit http://www.swi-prolog.org/ To unsubscribe, send a plaintext mail with "unsubscribe prolog <e-mail>" in its body to majordomo@... |
|
|
Re: strings and atoms with JPLOn Wed, Apr 30, 2008 at 02:36:05PM +0100, Paul Singleton wrote:
> Nor is there in Prolog (except in input, output and source > syntax). Ok, this is the answer I was looking for :) > Of course, if you use JPL's convenience methods to create terms > from Prolog source fragments, then you'll still need to quote > such atoms, e.g. > > jpl.Query.oneSolution("assert(is_an_atom('2+2'))") Yes of course. |
|
|
|
| Free Forum Powered by Nabble | Forum Help |