I created a modified data structure in OCaml, however, when I go to it, it gives a strange error,
Here is my code
type vector = {a:float;b:float};;
type vec_store = {mutable seq:vector array;mutable size:int};;
let max_seq_length = ref 200;;
exception Out_of_bounds;;
exception Vec_store_full;;
let vec_mag {a=c;b=d} = sqrt( c**2.0 +. d**2.0);;
let make_vec_store() =
let vecarr = ref ((Array.create (!max_seq_length)) {a=0.0;b=0.0}) in
{seq= !vecarr;size=0};;
When I do this at the top level of ocaml
let x = make _ vec _store;;
and then try to do x.sizeI get this error
Error: This expression has type unit -> vec_store
but an expression was expected of type vec_store
Seems to be a problem? I can’t understand why this will not work.
Thanks Faisal
source
share