I want to do the command #use "a.ml" conditionally i.e., in 'if statement' as shown below...
let funs = function (true) -> #use "1.ml"
is there any way of doing it?
| (false)-> #use "2.ml";;
I want to do the command #use "a.ml" conditionally i.e., in 'if statement' as shown below...
let funs = function (true) -> #use "1.ml"
is there any way of doing it?
| (false)-> #use "2.ml";;
The #use
directive is part of the interpretive environment (REPL) of the OCaml toplevel. It's not a construct of the OCaml language itself. So your example code makes no sense as an OCaml program.
However, it's pretty clear what you want to do: you want to choose between two implementations of a set of functions (i.e., two modules) at runtime.
This is what first-class modules are for. See this excellent SO answer.