Re: String is not string in SWI prolog , part/2.
- From: "Pierpaolo BERNARDI" <pierpaolo@xxxxxxxxxxxxx>
- Date: 25 May 2006 06:39:36 +0200
On Thu, 25 May 2006 03:56:14 +0200, <newser.bbs@xxxxxxxxxxxxxxxxx> wrote:
) , I gave codes for getting line:
--------------------------------------------------------
assertz((get_line(L):-get_char(C),(C=end_of_file->copy_term('',L);C='\n'->copy_term(C,L);get_line(L1),atom_concat(C,L1,L)))).
assertz((eof:-get_char(C),(C=end_of_file,!;unget_char(C),fail))).
---------------------------------------------------------
In these codes , you can see that I use atoms for strings ,
(see the atom_concat ?)
swi has read_line_to_codes/[2,3], which can be used as a base.
I'd use:
newser_read_line(Stream,LineAsAtom,LineAsCodes) :-
read_line_to_codes(Stream,LineAsCodes),
( LineAsCodes = end_of_file
-> LineAsAtom = end_of_file
; atom_codes(LineAsAtom,LineAsCodes
).
But I have read about inside lisp before , and it is said that
an atom was presented as an ID Number inside lisp . If this is
also true in prolog , my represenation for strings might cause
problems. Eg for an web page of thousands of lines ,
the number of atoms it created might become up to millions,
thus millions of ID Numbers will be wasted unnecessarily and
it might cause slow-down in compiling or interpretation of
my program.
This is not a problem in swi prolog.
In other prolog implementations, it may or may not be a problem,
depending on whether they do or do not do atom garbage collection.
P.
--
Anything below this line is being added by the newsserver
Inviato da X-Privat.Org - Registrazione gratuita http://www.x-privat.org/join.php
.
- References:
- String is not string in SWI prolog , part/2.
- From: newser . bbs
- Re: String is not string in SWI prolog , part/2.
- From: Mauro Di Nuzzo
- Re: String is not string in SWI prolog , part/2.
- From: newser . bbs
- Re: String is not string in SWI prolog , part/2.
- From: Mauro DiNuzzo
- Re: String is not string in SWI prolog , part/2.
- From: newser . bbs
- String is not string in SWI prolog , part/2.
- Prev by Date: Re: How to replace a term to the inside of an other term?
- Next by Date: [ICLP'06] Call for participation
- Previous by thread: Re: String is not string in SWI prolog , part/2.
- Next by thread: read doesn't read back from writeq
- Index(es):
Relevant Pages
|
|