File: tfloat_record.ml

package info (click to toggle)
js-of-ocaml 6.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 37,932 kB
  • sloc: ml: 135,957; javascript: 58,364; ansic: 437; makefile: 422; sh: 12; perl: 4
file content (48 lines) | stat: -rw-r--r-- 892 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
(* TEST *)

module Float_record : sig
  type t = private float;;

  val make : float -> t;;
  val from : t -> float;;

  type s = {f : t};;
end = struct
  type t = float;;

  let make f = f;;

  let from t = t;;

  type s = {f : t};;
end

module Float_array = struct
  let small_float_array x =
    [|1.;2.;3.|], x

  let longer_float_array x =
    [|1.;2.;3.;4.;5.;6.;7.;8.;9.;0.;
      1.;2.;3.;4.;5.;6.;7.;8.;9.;0.;
      1.;2.;3.;4.;5.;6.;7.;8.;9.;0.;
      1.;2.;3.;4.;5.;6.;7.;8.;9.;0.;|], x
end

let s = { Float_record.f = Float_record.make 1.0 };;

print_float (Float_record.from s.Float_record.f);;
print_newline ();;


let b = Float_array.small_float_array 12
let c = (Float_array.longer_float_array [@inlined]) 34

let print_array a =
  Array.iter (fun f ->
      print_float f;
      print_newline ()) a;
  print_newline ()

let () =
  print_array (fst b);
  print_array (fst c);