Created
January 15, 2015 10:48
-
-
Save sugitach/544bb8cba7a5cc10c9de 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
(* データ読み込み *) | |
#use "person_t.ml" | |
(* 目的:person_t のリストから指定された血液型の人数を返す *) | |
(* count_ketsueki : string -> person_t list -> int *) | |
let rec count_ketsueki bld lst = | |
match lst with | |
[] -> 0 | |
| first :: rest -> count_ketsueki bld rest + | |
if (first.blood = bld) | |
then 1 | |
else 0 | |
(* テスト *) | |
let test1_1 = count_ketsueki "A" test_data1 = 1 | |
let test1_2 = count_ketsueki "B" test_data1 = 2 | |
let test1_3 = count_ketsueki "AB" test_data1 = 1 | |
(* 目的:person_t のリストから人の名前のリストを返す *) | |
(* person_namae : person_t list -> string list *) | |
let rec person_namae lst = | |
match lst with | |
[] -> [] | |
| first :: rest -> first.name :: person_namae rest | |
(* テスト *) | |
let test2 = person_namae test_data1 = ["ishimaru";"tachikawa";"kanehara";"kata";"hidaka";"shikiuchi"] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment