Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: -- (:)
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 Archives:
Bug reports: FAQ:
Beginner's list: