I would like to express something like the following:
if b then
let value = ... in
else
let value = .... in
let double = value * 2
But it seems that Ocaml does not allow this syntax. If I don’t want to repeat the let double = value * 2 part, do I have to define value as a reference?
Thank you very much!
Your trouble is that you’re thinking of this imperatively (conditionally assign to a variable) rather than functionally (bind a name to the result of an expression):