Comment detail

固定長データ (Nested Flatten)
処理順依存です。値を作るとき、レコード型定義で後ろにあるものから
先に評価されてしまうので、typeの項目を逆さにしました。
 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
type daily_menu =
  { dinnar : string;
    lunch : string;
    breakfast : string;
    date : int;
  }

type person = 
  { menus : daily_menu array;
    month : int;
    year : int;
    age : int;
    sex : char;
    name : string;
    family : string;
  }


let main filepath =
  let in_file = open_in filepath in

  let create len (*in_file*) = 
    let s = String.create len in
    really_input in_file s 0 len; s
  in

  Array.init 500 (fun _ -> 
    { family = create 12;
      name = create 12;
      sex = (create 1).[0];
      age = int_of_string (create 3);
      year = int_of_string (create 4);
      month = int_of_string (create 2);
      menus = Array.init 31 (fun _ ->
        { date = int_of_string (create 2);
          breakfast = create 500;
          lunch = create 500;
          dinnar = create 500;
        } )
    } );;

Index

Feed

Other

Link

Pathtraq

loading...