🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fj.lang.prolog
Article #76

Re: integer to string in Prolog

#76
From: Martin Sondergaard
Date: Thu, 02 Apr 1998 00:00
23 lines
1244 bytes
John Wong wrote:

> Does anybody know how to convert an integer to string in Prolog???  Thanks!

      It depends on the version of Prolog you are using.
The "name" functor suggested by NIDE Naoyuki works in one version of Prolog
that I have, but not in another.
    PD Prolog uses a special funtor called "atoi" which stands for "Ascii TO
Integer".
It can convert from an Ascii number string to an integer, or vice versa.
Other versions of Prolog should all have something similar, but probably with a
different name.
It works like this :

atoi( Ascii, Integer )
--------------------

?- X is 3 + "2".
No
?- atoi( "2", Integer ),  X is 3 + Integer.
X = 5
?-
Technical Details
Message-ID: <352408B8.7C11616A@sondergaard.demon.co.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <6fdvl2$lt7@bgtnsc02.worldnet.att.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1217ff,c92aabd597b992cb
X-Google-Attributes: gid1217ff,public
From: Martin Sondergaard <martin@sondergaard.demon.co.uk>
Subject: Re: integer to string in Prolog
Date: 1998/04/02
Message-ID: <352408B8.7C11616A@sondergaard.demon.co.uk>
X-Deja-AN: 340320133
Content-Transfer-Encoding: 7bit
X-NNTP-Posting-Host: sondergaard.demon.co.uk [194.222.250.149]
References: <6fdvl2$lt7@bgtnsc02.worldnet.att.net>
Content-Type: text/plain; charset=us-ascii
MIME-Version: 1.0
Newsgroups: fj.lang.prolog