Variable data in OCaml

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

+3
source share
3 answers

make_vec_store - . let x = make_vec_store, x , let x = 1, x 1. , , . make_vec_store () ( "" ), let x = make_vec_store ().

+12

x = make_ vec_store()

+4

. , :

# let x = make_vec_store;;
val x : unit -> vec_store = <fun>

, repl . , x <fun>, unit vec_store.

# let x = 1;;
val x : int = 1

, x int 1.

+2

Source: https://habr.com/ru/post/1721154/


All Articles