Last active
August 29, 2015 14:06
-
-
Save akanehara/c367a0848a958a6c5437 to your computer and use it in GitHub Desktop.
乙女座の人の名前のみからなるリストを返す関数
This file contains 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; | |
} | |
(* 乙女座かどうかを返す *) | |
(* is_otomeza : date_t -> bool *) | |
let is_otomeza { month = m; day = d } = | |
let x = m * 100 + d in | |
0824 <= x && x <= 0923;; | |
(* 目的:乙女座の人の名前のみからなるリストを返す関数 *) | |
(* otomeza : person_t list -> string list *) | |
let rec otomeza persons = | |
match persons with | |
[] -> [] | |
| { name = n; birthday = b } :: ps -> if is_otomeza b then n :: otomeza ps | |
else otomeza ps | |
let people = [{name = "ほげ"; | |
height = 1.73; | |
weight = 73.2; | |
birthday = { month=10; day=8; }; | |
blood = "A";}; | |
{name = "ふが"; | |
height = 1.60; | |
weight = 59.2; | |
birthday = { month=12; day=15; }; | |
blood = "A";}; | |
{name = "みー"; | |
height = 1.64; | |
weight = 50.4; | |
birthday = { month=8; day=17; }; | |
blood = "O";}; | |
{name = "ぱー"; | |
height = 1.73; | |
weight = 73.2; | |
birthday = { month=1; day=8; }; | |
blood = "A";}; | |
{name = "ぐう"; | |
height = 1.60; | |
weight = 59.2; | |
birthday = { month=2; day=15; }; | |
blood = "A";}; | |
{name = "へろ"; | |
height = 1.64; | |
weight = 50.4; | |
birthday = { month=3; day=17; }; | |
blood = "O";}; | |
{name = "ぼえ"; | |
height = 1.73; | |
weight = 73.2; | |
birthday = { month=4; day=8; }; | |
blood = "A";}; | |
{name = "もょもと"; | |
height = 1.60; | |
weight = 59.2; | |
birthday = { month=5; day=15; }; | |
blood = "A";}; | |
{name = "ぱん"; | |
height = 1.64; | |
weight = 50.4; | |
birthday = { month=6; day=17; }; | |
blood = "O";}; | |
{name = "ぶー"; | |
height = 1.73; | |
weight = 73.2; | |
birthday = { month=7; day=8; }; | |
blood = "A"; }; | |
{name = "てるみん"; | |
height = 1.60; | |
weight = 59.2; | |
birthday = { month=8; day=15; }; | |
blood = "A"; }; | |
{name = "ねこ"; | |
height = 1.64; | |
weight = 50.4; | |
birthday = { month=9; day=17; }; | |
blood = "O"; }; | |
{name = "がりがりさん"; | |
height = 1.64; | |
weight = 50.4; | |
birthday = { month=11; day=17; }; | |
blood = "O";}];; | |
let otomeza1 = otomeza people = ["ねこ"];; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment