第6章練習問題
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
(* --- 第6章問題 --- *) | |
(* 1. 型エラー *) | |
(* 関数squareにはint型値が渡されないといけない *) | |
# let square x = x * x ;; | |
val square : int -> int = <fun> | |
# square 3. ;; | |
Error: This expression has type float but an expression was expected of type | |
int | |
(* 2. 未定義の変数 *) | |
(* 変数piが定義されていない *) | |
# let circle = 2. *. pi *. r ;; | |
Error: Unbound value pi | |
(* 3. 構文エラー *) | |
(* "関数名は,変数名と同様にアルファベットの小文字で始まらなくてはなりません。"p.20 *) | |
(* 上の規則により,構文エラーが出たと考えられる *) | |
# let TV bangumi youbi = bangumi ^ "は" ^ youbi ^ "に放映です." ;; | |
Error: Syntax error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment