Skip to content

Instantly share code, notes, and snippets.

@shubhamkumar13
Created October 12, 2020 00:51
Show Gist options
  • Select an option

  • Save shubhamkumar13/cf892baf46466a1221d04b9cf2df04c9 to your computer and use it in GitHub Desktop.

Select an option

Save shubhamkumar13/cf892baf46466a1221d04b9cf2df04c9 to your computer and use it in GitHub Desktop.
Convert string to string list
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