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
| let rec iterpow(i,res,x,n) = | |
| if i > n then res else iterpow(i+1,res *. x,x,n) |
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
| let rec pow(x,n) = | |
| if n <= 1 then x | |
| else let stack = pow(x,n/2) in | |
| if n mod 2 = 0 then stack*stack | |
| else x*stack*stack |
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
| let rec pow(x,n) = | |
| if n <= 1 then x else x * pow(x,n-1) |
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
| let sum_and_diff (x, y) = (x + y, x - y) | |
| let f (x, y) = ((x+y)/2,(x-y)/2) |
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
| let geo_mean x y = sqrt(x *. y) |
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
| let bmi_check (name, height, weight) = | |
| let bmi = weight /. (height *. height) in | |
| if bmi < 18.5 then name ^ "さんはやせています" | |
| else if bmi < 25.0 then name ^ "さんは標準です" | |
| else if bmi < 30.0 then name ^ "さんは肥満です" | |
| else name ^ "さんは肥満です" |
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
| let f b1 b2 = if(b1 < b2 = b1 > b2 = false) then true else false |
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
| let f b1 b2 = if(b1 > b2 = b1 < b2) then true else false |
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
| let capitalize chr = | |
| let ascii = int_of_char chr in | |
| if ascii > 96 && ascii < 123 then char_of_int(ascii-32) else chr |
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
| let string_of_doll doll = | |
| let rate = 114.32 in | |
| let yen = doll *. rate in | |
| string_of_float(doll) ^ "dollars are " ^ string_of_float(yen) ^ " yen. " |