Re: Manipulating Strings in Sicstus Prolog
- From: Jan Wielemaker <jan@xxxxxxxxxxxxxxxxxxx>
- Date: 09 Jun 2006 07:31:42 GMT
On 2006-06-08, nima.kaviani@xxxxxxxxx <nima.kaviani@xxxxxxxxx> wrote:
Hi all,
does anybody know how I can convert a string to a list of chars in
Sicstus? It is really easy in SWI-Prolog simply by using the predicate
string_to_list, but in sicstus I am having problems working with
strings. any suggestion?
SWI-Prolog provides strings as a primitive datatype. Actually the result
of adopting them from an early draft of the ISO standard. Strings never
made it to the standard. There is still some virtue in them, but in
general I think the ISO commitee took the right decision. I'd advice
against using them, except for two cases. Sometimes they offer a more
suitable compromise in terms of time and space and for some critical
applications it can be worthwhile. Most often they are used from C
to have arbitrary byte-sequences managed by the Prolog memory manager.
For representing text we have what is normally called a `string' in
Prolog: a list of character codes (one-letter atoms is an alternative
provided by ISO, generally causing more confusion that providing anything
useful). The other text representation is an atom, but as a general
text-store this only makes sense in systems providing atoms of arbitrary
length as well as atom-garbage-collection.
Conversion between the two is done using atom_codes(Atom, String).
Cheers --- Jan
.
- Follow-Ups:
- Re: Manipulating Strings in Sicstus Prolog
- From: Andreas Kochenburger
- Re: Manipulating Strings in Sicstus Prolog
- References:
- Manipulating Strings in Sicstus Prolog
- From: nima.kaviani@xxxxxxxxx
- Manipulating Strings in Sicstus Prolog
- Prev by Date: Re: Prolog for .NET ?
- Next by Date: :- at the beginning for assertional coding
- Previous by thread: Manipulating Strings in Sicstus Prolog
- Next by thread: Re: Manipulating Strings in Sicstus Prolog
- Index(es):
Relevant Pages
|
|