Thread View: fj.lang.prolog
3 messages
3 total messages
Started by John Wong
Thu, 26 Mar 1998 00:00
integer to string in Prolog
Author: John Wong
Date: Thu, 26 Mar 1998 00:00
Date: Thu, 26 Mar 1998 00:00
2 lines
449 bytes
449 bytes
Does anybody know how to convert an integer to string in Prolog??? Thanks!
Re: integer to string in Prolog
Author: NIDE Naoyuki
Date: Mon, 30 Mar 1998 00:00
Date: Mon, 30 Mar 1998 00:00
18 lines
828 bytes
828 bytes
In <6fdvl2$lt7@bgtnsc02.worldnet.att.net> wongjohn@worldnet.att.net writes: > Does anybody know how to convert an integer to string in Prolog??? Thanks! name/2 will work. | ?- name(123, X). X = [49,50,51] ? /* ="123" */ yes | ?- name(X, "123"). X = 123 ? yes | ?- name(X, "abc"). X = abc ? yes nide@ics.nara-wu.ac.jp
Re: integer to string in Prolog
Author: Martin Sondergaard
Date: Thu, 02 Apr 1998 00:00
Date: Thu, 02 Apr 1998 00:00
23 lines
1244 bytes
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
?-
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads