Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Strings/substrings in prolog

679 views
Skip to first unread message

mick...@hotmail.com

unread,
Oct 29, 1999, 3:00:00 AM10/29/99
to
I'm a prolog newbie, I need to find out how strings are manipulated in
Prolog.

More specifically I need to find out how to split a string into
substrings and how to concatenate substrings into one string.

For example I need a predicate that splits a string into atoms, like:
Split(' ','Split this string',S).
S = [Split,this,string]

Sorry to bother with such a 'simple' question...

TIA
M. Sorensen


Sent via Deja.com http://www.deja.com/
Before you buy.

Tobias Göbel

unread,
Oct 30, 1999, 3:00:00 AM10/30/99
to
Hi!

This is indeed quite simple in Prolog.
Strings are just Lists of ASCII-Codes. So you can either say A=[97,98,99] or
you can say A="abc". This means the same in Prolog. And if you want to
concatenate two strings, you simply use append to do this:
?-append("simple","string",S).
S="simple string".
(prolog might print out the Ascii-list-representation at this point)

The suggested split predicate is now just a list manipulation task.

Tobias


mick...@hotmail.com schrieb in Nachricht <7vcioh$vv4$1...@nnrp1.deja.com>...

Paul Singleton

unread,
Nov 1, 1999, 3:00:00 AM11/1/99
to
"Tobias Göbel" wrote:

> This is indeed quite simple in Prolog.
> Strings are just Lists of ASCII-Codes.

...or of Unicode codes?

How many Prolog implementations are Unicode-capable
in the way that Java and (allegedly) Visual Basic are?

By which I think I mean that not only can a list-of-integers
accommodate 16-bit unsigned Unicode values, but that all
relevant built-in, library & GUI stuff handles Unicode strings
("uchars"?) consistently?

Paul Singleton

PS I don't really mean "how many" I mean "which " :-)

Mats Carlsson

unread,
Nov 2, 1999, 3:00:00 AM11/2/99
to
Paul Singleton <p.sin...@keele.ac.uk> writes:

> "Tobias Göbel" wrote:
>
> > This is indeed quite simple in Prolog.
> > Strings are just Lists of ASCII-Codes.
>
> ...or of Unicode codes?
>
> How many Prolog implementations are Unicode-capable
> in the way that Java and (allegedly) Visual Basic are?
>
> By which I think I mean that not only can a list-of-integers
> accommodate 16-bit unsigned Unicode values, but that all
> relevant built-in, library & GUI stuff handles Unicode strings
> ("uchars"?) consistently?

SICStus Prolog 3.8 purports to do so (or generally any wide character
external encoding). Strings passed via the foreign language interface are
internally represented in UTF-8 encoding.

Mats Carlsson

Ray Reeves

unread,
Nov 2, 1999, 3:00:00 AM11/2/99
to
Amzi! Prolog

Paul Singleton wrote:

> "Tobias Göbel" wrote:
>
> > This is indeed quite simple in Prolog.
> > Strings are just Lists of ASCII-Codes.
>
> ...or of Unicode codes?
>
> How many Prolog implementations are Unicode-capable
> in the way that Java and (allegedly) Visual Basic are?
>
> By which I think I mean that not only can a list-of-integers
> accommodate 16-bit unsigned Unicode values, but that all
> relevant built-in, library & GUI stuff handles Unicode strings
> ("uchars"?) consistently?
>

0 new messages