Created
October 30, 2014 10:44
-
-
Save sugitach/66f9ce1c3b2e12d1769d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* 型定義 *) | |
type date_t = { | |
month : int; | |
day : int; | |
} | |
type person_t = { | |
name : string; | |
height : float; | |
weight : float; | |
birthday : date_t; | |
blood : string; | |
} | |
(* テスト用データ *) | |
let test_data1 = [ | |
{ | |
name = "ishimaru"; | |
height = 1.73; | |
weight = 73.2; | |
birthday = { month = 10; day = 8; }; | |
blood="A"; | |
}; | |
{ | |
name = "tachikawa"; | |
height = 1.60; | |
weight = 59.2; | |
birthday = { month = 12; day = 15; }; | |
blood = "B"; | |
}; | |
{ | |
name = "kanehara"; | |
height = 1.60; | |
weight = 59.2; | |
birthday = { month = 12; day = 15; }; | |
blood = "B"; | |
}; | |
{ | |
name = "kata"; | |
height = 1.60; | |
weight = 59.2; | |
birthday = { month = 12; day = 15; }; | |
blood = "O"; | |
}; | |
{ | |
name = "hidaka"; | |
height = 1.60; | |
weight = 59.2; | |
birthday = { month = 12; day = 15; }; | |
blood = "C"; | |
}; | |
{ | |
name = "shikiuchi"; | |
height = 1.60; | |
weight = 59.2; | |
birthday = { month = 12; day = 15; }; | |
blood = "AB"; | |
} | |
] | |
let rec ketsueki_shukei lst = match lst with | |
[] -> (0, 0, 0, 0, 0) | |
| { name = n; height = h; weight = w; birthday = b; blood = bl } :: rest -> | |
let (a, b, o, ab, other) = ketsueki_shukei rest in | |
if bl = "A" then (a + 1, b, o, ab, other) | |
else if bl = "B" then (a, b + 1, o, ab, other) | |
else if bl = "O" then (a, b, o + 1, ab, other) | |
else if bl = "AB" then (a, b, o, ab + 1, other) | |
else (a, b, o, ab, other + 1) | |
let t0 = ketsueki_shukei [] = (0, 0, 0, 0, 0) | |
let t1 = ketsueki_shukei test_data1 = (1, 2, 1, 1, 1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment