Coming from a Java and C background, grasping some concepts of Ocaml has been quite interesting. One such is, getting a/multiple statement to run inside a for loop.
let test_method (x:vector list)(vec:vector) =
if List.length x != 0 then
{a=0.;b=0.} (* Return a vector of 0,0 *)
else
for i = 0 to List.length x do
let key = {a=(List.nth x i).a;b=(List.nth x i).b}
done;;
the error that i get is done;; is an unexpected token. Why is this happening? this happens even if i do this
let test_method (x:vector list)(vec:vector) =
if List.length x != 0 then
{a=0.;b=0.} (* Return a vector of 0,0 *)
else
for i = 0 to List.length x do
let key = {a=(List.nth x i).a;b=(List.nth x i).b} in
let value = vec_neg key;
done;;
where vec_neg is a method that works fine that negates the vector type.
Any help would be greatly appreciated.