駒込がなぜか見つからない事件
code:ocaml
utop # get_ekikan_node (inserts_ekikan Empty global_ekikan_list) "駒込";;
駒込 > 営団成増
駒込 > 和光市
駒込 > 平和台
駒込 > 営団赤塚
駒込 > 氷川台
駒込 > 要町
駒込 > 池袋
駒込 > 護国寺
駒込 > 飯田橋
駒込 > 銀座一丁目
駒込 > 門前仲町
駒込 < 麻布十番
駒込 not found
- : ekikan_tree_t option = None
code:ocaml
(* これがおかしい!!!! *)
let ekikan_a = {kiten="営団成増"; shuten="和光市"; keiyu="有楽町線"; kyori=2.1; jikan=3}
let ekikan_b = {kiten="営団赤塚"; shuten="営団成増"; keiyu="有楽町線"; kyori=1.5; jikan=2}
let tree_a = insert_ekikan Empty ekikan_a
let tree_b = insert_ekikan tree_a ekikan_b
code:ocaml
val ekikan_a : ekikan_t =
{kiten = "営団成増"; shuten = "和光市"; keiyu = "有楽町線";
kyori = 2.1; jikan = 3}
val ekikan_b : ekikan_t =
{kiten = "営団赤塚"; shuten = "営団成増"; keiyu = "有楽町線";
kyori = 1.5; jikan = 2}
val tree_a : ekikan_tree_t =
val tree_b : ekikan_tree_t =
なぜ和光市が二つあるのか...
code:ocaml
utop # get_ekikan_node (inserts_ekikan Empty global_ekikan_list) "営団成増";;
営団成増 == 営団成増
- : ekikan_tree_t option =
Some
(Node (Node (Empty, "和光市", [], Empty), "営団成増",
Node (Empty, "和光市", [], Empty)))
解決。以下のように修正したら直りました...
code:diff
diff --git a/metro.ml b/metro.ml
index 842200b..0b25dd7 100644
--- a/metro.ml
+++ b/metro.ml
@@ -398,7 +398,7 @@ let insert_ekikan ekikan_tree ekikan =
| Node (t1, ekimei, ekimei_kyori_pairs, t2) ->
if kiten0 = ekimei then
- Node (t1, ekimei, ((shuten0, kyori0) :: ekimei_kyori_pairs), t1)
+ Node (t1, ekimei, ((shuten0, kyori0) :: ekimei_kyori_pairs), t2)
else if kiten0 < ekimei then
Node ((insert_ekikan0 t1 kiten0 shuten0 kyori0), ekimei, ekimei_kyori_pairs, t2)
else