English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Re: "ocaml_beginners"::[] string to list
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-02-17 (23:05)
From: Issac Trotts <ijtrotts@u...>
Subject: Re: [Caml-list] Re: "ocaml_beginners"::[] string to list
Christian Schaller wrote:

>Thanks a lot for this.  I am somewhat surprised, since this should be a
>built-in function.  Anyway, maybe you can help me with this one, too:  is
>there also a conversion from character to string or appending a character in
>front or at the end of a string?
>- Chris
Hi Chris,

Here's a way to make a string from a char:

# let c = 'a';;
val c : char = 'a'
# String.make 1 c;;
- : string = "a"

It's possible to prepend and append like this:

# (String.make 1 c) ^ "foo";;
- : string = "afoo"
# "foo" ^ (String.make 1 c);;
- : string = "fooa"

but it is probably more efficient to use the Buffer 
module (buffer.mli in /usr/lib/ocaml or 


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