Subject: Re: [SWIPL] Converting terms to strings

From: Nicos Angelopoulos <[email-masked]>
Date: Sat, 7 Apr 2001 15:05:14 +0100 (BST)

try,

% pl
Welcome to SWI-Prolog (Version 4.0.2)
Copyright (c) 1990-2000 University of Amsterdam.
Copy policy: GPL-2 (see www.gnu.org)
For help, use ?- help(Topic). or ?- apropos(Word).
?- term_to_atom( box(red,'is red'), Atom ), atom_codes( Atom, Codes).
Atom = 'box(red, \'is red\')'
Codes = [98, 111, 120, 40, 114, 101, 100, 44, 32|...]

Nicos.

On Fri, 6 Apr 2001, Kourakos-Mavromichalis Evagelos wrote:

> Hello,
> I'd like to know if it's possible to convert a term like:
> box(red,'is red')
> to a list:
> [ A1, A2,..., A17 ]
> where Ax are the ASCII values of chars of the term.
> 
> I think that the only build in predicate that achieves this is the 
> string_to_list( ?String, ?List ). 
> but how we convert the box(red,'is red') to a string?
> 
> Also, is it possible to write such terms that contains strings to text
> files?
> 
> Thanks in advance,
> Vangelis Mavromichalis
> PhD Student
> 
> 
> ----------------
> * To UNSUBSCRIBE, please use the HTML form at
> 
>     http://www.swi.psy.uva.nl/projects/SWI-Prolog/index.html#mailinglist
> 
> or send mail to [email-masked] using the Subject: "unsubscribe"
> (without the quotes) and *no* message body.
> 
> ** An ARCHIVE of this list is maintained at
> 
>     http://www.swi.psy.uva.nl/projects/SWI-Prolog/mailinglist/archive/
>