From: Diego Olivier Fernandez Pons <Diego-Olivier.FERNANDEZ-PONS@cicrp.jussieu.fr>
To: Nicolas George <nicolas.george@ens.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] [RANT] String representation (was: Strings as arrays or lists...)
Date: Tue, 4 Mar 2003 13:43:20 +0100 (NFT) [thread overview]
Message-ID: <Pine.A41.4.44.0303041312560.4431978-100000@ibm1.cicrp.jussieu.fr> (raw)
In-Reply-To: <20030303221022.GA24499@clipper.ens.fr>
Bonjour,
Some of the features you wish are 'not so hard to implement', at least
if you already have 'conceptually bugged low-level' strings :
> - Strings need fast concatenation and parts extraction, arrays do
> not need that.
Any 'fast mergeable' data structure will do it :
- trees of strings
- fast catenable lists
> - Arrays need fast random access by numeric index, strings do not
> need that.
You can easily hava a (log n/k + 1) acces where n is the total size of
the string and k is the size of each bucket (if you choose a data
structure with constant buffer size)
> - string is an abstract type, with fast concatenation (especially
> when one of the operands is not used anymore; this is like
> tail-recursion optimisation, but for strings);
You just have to free the unused buckets of you string. If you really
want tail recursive functions try a 'list' based data structure. That
seems to be what Alain Frisch did in CDuce.
> - there is also a `cursor' type, which is something like a pair
> (string, index in that string);
Easy... You can even do better : using a zipper you have constant
acces to the pointed element (instead of log n), with some bookkeeping
every time you move the index.
> - there are functions to move cursors forward and backward, take
> substrings between two cursors, etc.;
Zippers only allow one (functional) pointer by data structure. For
this you will have to stick to an index with logarithmic time acces.
You can of course mix both (zippers + indexes)
> - there is a buffer type which is a byte array for low-level
> operations, and conversion functions between buffers and strings,
> with several possible encodings;
Yes... strings.
Diego Olivier
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2003-03-04 12:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-03 18:28 [oliver: Re: [Caml-list] Strings as arrays or lists...] Oliver Bandel
2003-03-03 20:10 ` brogoff
2003-03-03 21:05 ` William Lovas
2003-03-03 21:32 ` Basile STARYNKEVITCH
2003-03-03 22:10 ` [Caml-list] [RANT] String representation (was: Strings as arrays or lists...) Nicolas George
2003-03-04 12:43 ` Diego Olivier Fernandez Pons [this message]
2003-03-04 16:14 ` William D. Neumann
2003-03-04 18:38 ` Xavier Leroy
2003-03-04 18:50 ` William D. Neumann
2003-03-04 19:01 ` Nicolas George
[not found] ` <Pine.A41.4.44.0303041312560.4431978-100000@ibm1.cicrp.juss ieu.fr>
2003-03-04 13:49 ` David Chase
2003-03-04 0:20 ` [oliver: Re: [Caml-list] Strings as arrays or lists...] Issac Trotts
2003-03-04 0:24 ` Alain.Frisch
2003-03-04 1:06 ` Issac Trotts
2003-03-04 0:39 ` Olivier Andrieu
2003-03-04 0:39 ` brogoff
2003-03-03 21:40 ` [Caml-list] extensional polymorphism james woodyatt
2003-03-04 1:10 ` brogoff
2003-03-04 2:04 ` james woodyatt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.A41.4.44.0303041312560.4431978-100000@ibm1.cicrp.jussieu.fr \
--to=diego-olivier.fernandez-pons@cicrp.jussieu.fr \
--cc=caml-list@inria.fr \
--cc=nicolas.george@ens.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox