I am trying this simple code to split a string to a list by a separator:

open String;;
let ss = "/usr/bin/ocaml";;
let sslist = String.split_on_char '/' ss  in
    print_endline sslist;;

It is giving error:

$ ocaml testing.ml

File "testing.ml", line 5, characters 13-33:
Error: Unbound value String.split_on_char

I am sure it is something very basic but I am not able to solve it. Removing open String or using #require "string" also does not work.

Where is the problem and how can it be solved? Thanks for your help.

1 Answers

0
glennsl On Best Solutions

String.split_on_char is only available since 4.04.0, as per the docs.

You really should upgrade, but in case you can't, refer to this question for alternatives.