* jabbr
@ 2005-02-10 16:22 Paul Argentoff
2005-02-10 17:18 ` Newbe question: Strings <-> char lists Juancarlo Añez
0 siblings, 1 reply; 6+ messages in thread
From: Paul Argentoff @ 2005-02-10 16:22 UTC (permalink / raw)
To: caml-list
Hi ppl.
Did anyone write anything with jabbr? I have some questions.
--
Yours truly, WBR, Paul Argentoff.
Jabber: paul@jabber.rtelekom.ru
RIPE: PA1291-RIPE
^ permalink raw reply [flat|nested] 6+ messages in thread
* Newbe question: Strings <-> char lists
2005-02-10 16:22 jabbr Paul Argentoff
@ 2005-02-10 17:18 ` Juancarlo Añez
2005-02-10 17:36 ` [Caml-list] " Alex Baretta
2005-02-10 17:48 ` Olivier Andrieu
0 siblings, 2 replies; 6+ messages in thread
From: Juancarlo Añez @ 2005-02-10 17:18 UTC (permalink / raw)
To: caml-list
How does one convert a char list to a string?
Why aren't functions for converting char lists to strings and back part of
the standard library.
Haskell allows treating any string as a char list. I don't know what it does
behind the scenes, but it is mighty convenient.
Juanco
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Newbe question: Strings <-> char lists
2005-02-10 17:18 ` Newbe question: Strings <-> char lists Juancarlo Añez
@ 2005-02-10 17:36 ` Alex Baretta
2005-02-10 19:19 ` Juancarlo Añez
2005-02-10 17:48 ` Olivier Andrieu
1 sibling, 1 reply; 6+ messages in thread
From: Alex Baretta @ 2005-02-10 17:36 UTC (permalink / raw)
To: Juancarlo Añez; +Cc: caml-list
Juancarlo Añez wrote:
> How does one convert a char list to a string?
>
> Why aren't functions for converting char lists to strings and back part of
> the standard library.
>
> Haskell allows treating any string as a char list. I don't know what it does
> behind the scenes, but it is mighty convenient.
As far as I now, Haskell actually implements strings as lists of
characters, which might or might not be a useful abstraction of a
string, but it is definitely inconvenient from the standpoint of
computational and memory complexity. This explains the design choices
behind the Ocaml string type as well as why a mapping from strings to
char lists is not "standard" in Ocaml.
Alex
--
*********************************************************************
http://www.barettadeit.com/
Baretta DE&IT
A division of Baretta SRL
tel. +39 02 370 111 55
fax. +39 02 370 111 54
Our technology:
The Application System/Xcaml (AS/Xcaml)
<http://www.asxcaml.org/>
The FreerP Project
<http://www.freerp.org/>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Newbe question: Strings <-> char lists
2005-02-10 17:18 ` Newbe question: Strings <-> char lists Juancarlo Añez
2005-02-10 17:36 ` [Caml-list] " Alex Baretta
@ 2005-02-10 17:48 ` Olivier Andrieu
1 sibling, 0 replies; 6+ messages in thread
From: Olivier Andrieu @ 2005-02-10 17:48 UTC (permalink / raw)
To: juanca; +Cc: caml-list
Juancarlo Añez [Thu, 10 Feb 2005]:
>
> How does one convert a char list to a string?
Several possibilities :
- read the replies to your previous message
- read the FAQ
- subscribe to the beginner's list http://groups.yahoo.com/group/ocaml_beginners
> Why aren't functions for converting char lists to strings and back
> part of the standard library.
It's mighty inefficient in terms of memory : in a string one character
take approximately 1 byte, in a char list it needs 3 words (12 bytes
on IA32).
--
Olivier
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [Caml-list] Newbe question: Strings <-> char lists
2005-02-10 17:36 ` [Caml-list] " Alex Baretta
@ 2005-02-10 19:19 ` Juancarlo Añez
2005-02-10 20:55 ` Marcin 'Qrczak' Kowalczyk
0 siblings, 1 reply; 6+ messages in thread
From: Juancarlo Añez @ 2005-02-10 19:19 UTC (permalink / raw)
To: 'Alex Baretta'; +Cc: caml-list
Alex,
| As far as I now, Haskell actually implements strings as
| lists of characters,
I'm pretty sure that Haskell lets you *treat* strings as list of characters,
yet provides an efficient implementation of strings underneath.
| This explains the design choices behind the Ocaml string
| type as well as why a mapping from strings to char lists is
| not "standard" in Ocaml.
I don't mind that strings are not lists in OCAML, but I would still like to
convert (through a function) a string to a char list. There are no functions
for doing that in the stdlib, and I haven't been able to write my own (the
string concatenation operator does not accept a char [naturally] and there
are no "append" or "insert" functions in the library).
Juanco
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Newbe question: Strings <-> char lists
2005-02-10 19:19 ` Juancarlo Añez
@ 2005-02-10 20:55 ` Marcin 'Qrczak' Kowalczyk
0 siblings, 0 replies; 6+ messages in thread
From: Marcin 'Qrczak' Kowalczyk @ 2005-02-10 20:55 UTC (permalink / raw)
To: caml-list
Juancarlo Añez <juanca@suigeneris.org> writes:
> | As far as I now, Haskell actually implements strings as
> | lists of characters,
>
> I'm pretty sure that Haskell lets you *treat* strings as list of
> characters, yet provides an efficient implementation of strings
> underneath.
No, it's really a lazy list of characters underneath. There are
non-standard extensions, packed strings, but they a separate type.
--
__("< Marcin Kowalczyk
\__/ qrczak@knm.org.pl
^^ http://qrnik.knm.org.pl/~qrczak/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-02-10 20:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-10 16:22 jabbr Paul Argentoff
2005-02-10 17:18 ` Newbe question: Strings <-> char lists Juancarlo Añez
2005-02-10 17:36 ` [Caml-list] " Alex Baretta
2005-02-10 19:19 ` Juancarlo Añez
2005-02-10 20:55 ` Marcin 'Qrczak' Kowalczyk
2005-02-10 17:48 ` Olivier Andrieu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox