Last active
August 29, 2015 14:06
-
-
Save sugitach/d7a275971b286198063a to your computer and use it in GitHub Desktop.
Ocaml 勉強会
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
(* 月、日を入力して星座をもとめる *) | |
(* | |
牡羊座 Aries 3月21日から4月20生まれ | |
牡牛座 Taurus 4月21日から5月20生まれ | |
双子座 Gemini 5月21日から6月21日生まれ | |
蟹座 Cancer 6月22日から7月23日生まれ | |
獅子座 Leo 7月24日から8月23日生まれ | |
乙女座 Virgo 8月24日から9月23日生まれ | |
天秤座 Libra 9月24日から10月23日生まれ | |
蠍座 Scorpio 10月24日から11月22日生まれ | |
射手座 Sagittarius 11月23日から12月22日生まれ | |
山羊座 Capricorn 12月23日から1月20日生まれ | |
水瓶座 Aquarius 1月21日から2月19日生まれ | |
魚座 Pisces 2月20日から3月20日生まれ | |
*) | |
let aries = "牡羊座 Aries 3月21日から4月20生まれ" | |
let taurus = "牡牛座 Taurus 4月21日から5月20生まれ" | |
let gemini = "双子座 Gemini 5月21日から6月21日生まれ" | |
let cancer = "蟹座 Cancer 6月22日から7月23日生まれ" | |
let leo = "獅子座 Leo 7月24日から8月23日生まれ" | |
let virgo = "乙女座 Virgo 8月24日から9月23日生まれ" | |
let libra = "天秤座 Libra 9月24日から10月23日生まれ" | |
let scorpio = "蠍座 Scorpio 10月24日から11月22日生まれ" | |
let sagittarius = "射手座 Sagittarius 11月23日から12月22日生まれ" | |
let capricorn = "山羊座 Capricorn 12月23日から1月20日生まれ" | |
let aquarius = "水瓶座 Aquarius 1月21日から2月19日生まれ" | |
let pisces = "魚座 Pisces 2月20日から3月20日生まれ" | |
let isAries m d = (m = 3 && d >= 21) || (m = 4 && d <= 20) | |
let isTaurus m d = (m = 4 && d >= 21) || (m = 5 && d <= 20) | |
let isGemini m d = (m = 5 && d >= 21) || (m = 6 && d <= 21) | |
let isCancer m d = (m = 6 && d >= 22) || (m = 7 && d <= 23) | |
let isLeo m d = (m = 7 && d >= 24) || (m = 8 && d <= 23) | |
let isVirgo m d = (m = 8 && d >= 24) || (m = 9 && d <= 23) | |
let isLibra m d = (m = 9 && d >= 24) || (m = 10 && d <= 23) | |
let isScorpio m d = (m = 10 && d >= 24) || (m = 11 && d <= 22) | |
let isSagittarius m d = (m = 11 && d >= 23) || (m = 12 && d <= 22) | |
let isCapricorn m d = (m = 12 && d >= 23) || (m = 1 && d <= 20) | |
let isAquarius m d = (m = 1 && d >= 21) || (m = 2 && d <= 19) | |
let isPisces m d = (m = 2 && d >= 20) || (m = 3 && d <= 20) | |
let seiza m d = if isAries m d then aries else | |
if isTaurus m d then taurus else | |
if isGemini m d then gemini else | |
if isCancer m d then cancer else | |
if isLeo m d then leo else | |
if isVirgo m d then virgo else | |
if isLibra m d then libra else | |
if isScorpio m d then scorpio else | |
if isSagittarius m d then sagittarius else | |
if isCapricorn m d then capricorn else | |
if isAquarius m d then aquarius else | |
if isPisces m d then pisces else "ERROR" | |
let test1 = seiza 1 1 = capricorn | |
let test2 = seiza 2 2 = aquarius | |
let test3 = seiza 3 3 = pisces | |
let test4 = seiza 4 4 = aries | |
let test5 = seiza 5 5 = taurus | |
let test6 = seiza 6 6 = gemini | |
let test7 = seiza 7 7 = cancer | |
let test8 = seiza 8 8 = leo | |
let test9 = seiza 9 9 = virgo | |
let test10 = seiza 10 10 = libra | |
let test11 = seiza 11 11 = scorpio | |
let test12 = seiza 12 12 = sagittarius | |
let test13 = seiza 12 31 = capricorn |
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
(* 5.4 判別式 *) | |
let hanbetsushiki a b c = b *. b -. 4. *. a *. c | |
(* 5.5 解の個数 *) | |
let kai_no_kosuu a b c = if hanbetsushiki a b c < 0. then 0 else if hanbetsushiki a b c > 0. then 2 else 1 | |
(* 5.6 虚数解 *) | |
let kyosuukai a b c = if hanbetsushiki a b c < 0. then "虚数解あり" else "虚数解なし" | |
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
(* 身長(m)と体重(kg)からBMIを計算する *) | |
(* taikei float->float->float *) | |
let bmi height weight = weight /. (height *. height) | |
let taikei height weight = if (bmi height weight) < 18.5 then "やせ" else | |
if (bmi height weight) < 25. then "標準" else | |
if (bmi height weight) < 30. then "肥満" else "高度肥満" | |
let test1 = taikei 1.73 50. = "やせ" | |
let test1 = taikei 1.73 55. = "やせ" | |
let test1 = taikei 1.73 57. = "標準" | |
let test1 = taikei 1.73 60. = "標準" | |
let test1 = taikei 1.73 65. = "標準" | |
let test1 = taikei 1.73 70. = "標準" | |
let test1 = taikei 1.73 73. = "標準" | |
let test1 = taikei 1.73 75. = "肥満" | |
let test1 = taikei 1.73 80. = "肥満" | |
let test1 = taikei 1.73 90. = "高度肥満" | |
let test1 = taikei 1.73 100. = "高度肥満" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment