Consider this OCaml code:
let coupe_inter i j cases =
let lcases = Array.length cases in
let low,_,_ = cases.(i)
and _,high,_ = cases.(j) in
low,high,
Array.sub cases i (j-i+1),
case_append (Array.sub cases 0 i) (Array.sub cases (j+1) (lcases-(j+1)))
Why the expression let ... and ... in is used in place of a let ... in let ... in sequence (like F# force you to do)? This construct seems quite frequent in OCaml code.
Thanks!
let x = a and y = b in chas the effect of definingxandy“simultaneously”. This means that the order of evaluation (aafter or beforeb) is unspecified (you must not assume thatawill be evaluated before), and thatxis not bound inbandynot bound ina, they are only available inc.I rarely use this construction, because I have been bitten in the past by the evaluation order thing. I often use the recursive variant of it,
let rec ... and ... in ...(where all variable bound are available everywhere), however, to define mutually recursive functions.