2010-01-01から1年間の記事一覧

Hashtblにはまった

OCamlのHashtblは,(=)演算子による構造比較なのに気がつかなくて,はまってしまった. # let key = ref 0;; val key = int ref {contents = 0} # Hashtbl.add tbl key ();; - : unit = () # Hashtbl.mem tbl key;; - : bool = true # key := 1;; // <-- key…

OCamlのバグ?

以下のようなヴァリアント型を定義する. type term_ = | Lit of int | Inc of term_ | IsZ of term_ | If of term_ * term_ * term_ | Pair of term_ * term_ | Fst of term_ | Snd of term_ type 'a term = term_ そして,これらのコンストラクタ用の関数…