1

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.

1
  • 2
    Your question is not very clear. Could you show us your code and exactly what you're trying to attempt? Are you sure you understand how cycling is done in functional programming?
    – PatJ
    May 4, 2015 at 14:20

1 Answer 1

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.