Browse thread
[Caml-list] Re: "ocaml_beginners"::[] string to list
- Issac Trotts
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Issac Trotts <ijtrotts@u...> |
| Subject: | [Caml-list] Re: "ocaml_beginners"::[] string to list |
Christian Schaller wrote:
>Hi everyone!
>
>I'm trying to find a built in function for converting a string to a list of
>characters, similar to SML's explode. Is something like this available?
>
>Thank you!
>
>- Chris
>
# let explode s =
let n = String.length s in
let rec aux k = if k = n then [] else s.[k] :: aux (k+1) in
aux 0;;
val explode : string -> char list = <fun>
# explode "foo";;
- : char list = ['f'; 'o'; 'o']
Issac
-------------------
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