関数の定義

2007年12月14日
1 分

これも let式を使う。

# let area_of_circle r = r *. r *. pi;;
val area_of_circle : float -> float = <fun>
# area_of_circle 1.0;;
- : float = 3.141529

引数の型を間違えないこと。

# area_of_circle 1;;
Characters 15-16:
area_of_circle 1;;
^
This expression has type int but is here used with type float