Created
October 12, 2020 00:51
-
-
Save shubhamkumar13/cf892baf46466a1221d04b9cf2df04c9 to your computer and use it in GitHub Desktop.
Convert string to string list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let str_to_strlst = fun str -> | |
| let rec loop = fun acc str -> | |
| match String.head str with | |
| | Some(x) when x = ',' -> loop acc (tail str) | |
| | Some(x) -> loop (x :: acc) (tail str) | |
| | None -> acc in | |
| loop [] str |> List.map (Printf.sprintf "%c") |> List.rev |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment