Reputation: 173
I am new to OCaml. I want to create new variables dynamically in a loop.
I tried few like x.(i), x.i, and tried to create names using fprintf.
Upvotes: 1
Views: 198
Reputation: 9377
You can't: OCaml is a static language in which the number, scope and name of variables is fixed. If you want a way to dynamically map strings to values, use a hashtable or map.
Upvotes: 2