String is not string in SWI prolog , part/2.
- From: newser.bbs@xxxxxxxxxxxxxxxxx
- Date: 24 May 2006 00:26:32 -0700
Last time , this topic was concluded that the string can't
be produced by directly written in the form of "...",
and it should be produced by procedures , eg
string_to_atom/2.
But the problem is not totally solved . Please look :
--------------------------------------------------------------------------------------
Welcome to SWI-Prolog (Multi-threaded, Version 5.2.13)
Copyright (c) 1990-2003 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
1 ?- string_to_atom(S,'This is a test').
S = "This is a test"
Yes
2 ?- string_to_atom(S,'This is a test'),
| assertz(db_string(S)),
| tell('c:\\test.txt'),
| listing(db_string/1),
| told.
S = "This is a test"
Yes
3 ?- db_string(S).
S = "This is a test"
Yes
4 ?- db_string(S),
| string_concat(S,S,S2).
S = "This is a test"
S2 = "This is a testThis is a test"
Yes
5 ?- retractall(db_string(_)).
Yes
6 ?- db_string(S).
No
7 ?- consult('c:\\test.txt').
% c:\test.txt compiled 0.00 sec, 520 bytes
Yes
8 ?- string_concat(S,S,S2).
ERROR: string_concat/3: Arguments are not sufficiently instantiated
9 ?- db_string(S),
| string_concat(S,S,S2).
ERROR: string_concat/3: Type error: `atomic' expected, found `[84, 104,
105, 115, 32, 105, 115, 32, 97, 32, 116, 101, 115, 116]'
---------------------------------------------------------------------------
You can see that , there is problem in the step 9 , although the
identical
codes get allright in the step 4.
For more clarification , just look the contents of c:\test.tx:
+++++++++++++++++++++++++++++++++++++++++
:- dynamic db_string/1.
db_string("This is a test").
++++++++++++++++++++++++++++++++++++++++++
It takes the form of db_string/1 with a parameter made of string .
But it just compiles to something that causes string_concat out of
order.
So weird !
Maybe that is because things chages if saved by listing and retrieved
by consult/1. For circumvention from such possibility ,
the following topic happens.
.
- Follow-Ups:
- Re: String is not string in SWI prolog , part/2.
- From: Mauro Di Nuzzo
- Re: String is not string in SWI prolog , part/2.
- Prev by Date: Re: It seems that I found prolog in prolog
- Next by Date: read doesn't read back from writeq
- Previous by thread: Prolog + C
- Next by thread: Re: String is not string in SWI prolog , part/2.
- Index(es):
Relevant Pages
|
|