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.
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.
The (^) operator concatenates two strings, e.g., # "hello" ^ ", " ^ "world!";; - : string = "hello, world!"
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.
You can use String.make :)
String.make 1 mychar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With