Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert char to string in OCaml

I want to convert a char to a string but I haven't found a function string_of_char. I want to do that using only functions from Pervasives.

like image 894
user3036156 Avatar asked Dec 07 '13 12:12

user3036156


People also ask

How do I match a string in OCaml?

There is a way to match strings as a list of characters, using a function from SML (which you can write in OCaml) called 'explode' and 'implode' which --respectively -- take a string to a char list and vice versa.

How do you add strings in OCaml?

The (^) operator concatenates two strings, e.g., # "hello" ^ ", " ^ "world!";; - : string = "hello, world!"

How do you capitalize a string in OCaml?

uppercase_ascii s is s with all lowercase letters translated to uppercase, using the US-ASCII character set. lowercase_ascii s is s with all uppercase letters translated to lowercase, using the US-ASCII character set.


1 Answers

You can use String.make :)

String.make 1 mychar
like image 150
rafix Avatar answered Sep 17 '22 12:09

rafix